UNPKG

@framejs/mixins

Version:

A set of mixing to help and speed up development of web components

18 lines (17 loc) 494 B
export const Mix = superclass => new MixinBuilder(superclass); /** * Creates a new class that extends with multiple mixins. * * @mixin * @example * class MyClass extends Mix(HTMLElement).with(Mixin, OtherMixin) {...} * @param {Function} superclass - The base class to extend upon. */ export class MixinBuilder { constructor(superclass) { this.superclass = superclass; } with(...mixins) { return mixins.reduce((c, mixin) => mixin(c), this.superclass); } }