mixins-decorator

1.0.3 • Public • Published

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

Readme

Keywords

Package Sidebar

Install

npm i mixins-decorator

Weekly Downloads

1

Version

1.0.3

License

ISC

Last publish

Collaborators

  • npm