mixins-decorator

Apply mixins to your classes

Usage no npm install needed!

<script type="module">
  import mixinsDecorator from 'https://cdn.skypack.dev/mixins-decorator';
</script>

README

Apply mixins to your JavaScript classes

With the mixins-decorator modules, you get the reap the benefits of mixins.

var mixin1 = { foo: function () { console.log('foo'); } };
var mixin2 = { bar: function () { console.log('bar'); } };

function Foo() {}

mixins(mixin1, mixin2)(Foo);

// Or, with ES6 classes

@mixins(mixin1, mixin2)
class Foo {}

var foo = new Foo();
foo.foo(); // foo
foo.bar(); // bar

Usage

Install mixins-decorator using npm:

npm install mixins-decorator

Then, use it in your code like so:

var mixins = require('mixins-decorator');

// ... Declare and define some mixins here ...

function Foo() {}

mixins(mixin1, mixin2)(Foo);

// Or, with ES6 classes

@mixins(mixin1, mixin2)
class Foo {}

License

mixins-decorator is ISC Licensed