create-mixin
Given these two classes.
class Base {
constructor () {
this.ranBaseConstructor = true
}
baseMethod () {
return 1
}
}
class Mixin {
constructor () {
this.ranMixinConstructor = true
}
someMethod () {
return 2
}
}
Create a new class mixing one class into another.
> const mixInto = require('create-mixin')
> class Something extends mixInto(Mixin)(Base) {}
Behaviour of new class.
> const something = new Something()
>
> something.baseMethod()
1
> something.someMethod()
2
>
> something.ranBaseConstructor
true
> something.ranMixinConstructor
undefined
> something instanceof Base
true
> something instanceof Mixin
false
create-mixin
Creates a mixin for use in a class extends expression.
createMixin(Src) ⇒ function
⏏
Kind: Exported function
Param | Type | Description |
---|
Src | class | The class containing the behaviour you wish to mix into another class. |
© 2018 Lloyd Brookes 75pound@gmail.com. Documented by jsdoc-to-markdown.