Mixiner is fast and small javascript library, that implement mixins in TypeScript or JavaScript classes.
This package has been deprecated.
// create mixin
class SpeackableMixin {
protected phrase: string;
public speak(): string {
return this.phrase;
}
}
// implement SpeackableMixin
@mixiner(SpeackableMixin)
class Duck {
protected phrase = 'quack';
public speak: () => string;
}
// create instance
const donald = new Duck();
// test instance
donald.speak(); // 'quack'
// create mixin
class SpeackableMixin {
speak() {
return this.phrase;
}
}
// implement SpeackableMixin
const Duck = mixiner(SpeackableMixin)(class Duck {
constructor() {
super();
this.phrase = 'quack';
}
});
// create instance
const donald = new Duck();
// test instance
donald.speak(); // 'quack'
Using npm:
$ npm install --save mixiner
TypeScript:
import mixiner from 'mixiner';
Node.js / CommonJS:
const mixiner = require('mixiner');
- Chrome
- Firefox
- Safari
- Edge
- IE 9-11
Tested in:
- Node.js 8
Mixiner is released under the MIT license