Nurturing Pluto's Martians
Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »

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

install

npm i mixins-decorator

Downloadsweekly downloads

2

version

1.0.3

license

ISC

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability