create-mixin
Creates a mixin for use in a class extends expression.
createMixin(Src) ⇒ function
⏏
Returns a function (accepting a single BaseClass
argument) which can be used to mix behaviour from the supplied Src
class into BaseClass
. Intended for use in an extends
expression.
Kind: Exported function
Param | Type | Description |
---|
Src | class | The class containing the behaviour you wish to mix into another class. |
Example
const mix = require('create-mixin')
class Greeter {
hello () { return 'Hello' }
}
class FriendlyArray extends mix(Greeter)(Array) {}
const friendlyArray = FriendlyArray.from([ 1, 2, 3 ])
console.log('Length:', friendlyArray.length)
console.log('Greeting:', friendlyArray.hello())
© 2018 Lloyd Brookes 75pound@gmail.com. Documented by jsdoc-to-markdown.