JSPM

mixin-es6

1.0.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 5
  • Score
    100M100P100Q25233F
  • License MIT

A truly working mixin utility for es6

Package Exports

  • mixin-es6

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (mixin-es6) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Mixin for ES6

A truly working mixin utility for es6

npm

Usage

An optional initializer can be provided in each mixin for initialisation purpose

const mix = require('mixin-es6');

class ColorMixin {
  initializer() {
    this._color = "white";
  }
  get color() {
    return this._color;
  }
  set color(v) {
    this._color = v;
  }
}

class ZCoordMixin {
  initializer() {
    this._z = 0;
  }
  get z() {
    return this._z;
  }
  set z(v) {
    this._z = v;
  }
}

class BaseClass {
  constructor(x, y) {
    this._x = x;
    this._y = y;
  }
  get x() {
    return this._x;
  }
  set x(v) {
    this._x = v;
  }
  get y() {
    return this._y;
  }
  set y(v) {
    this._y = v;
  }
}

class Rectangle extends mix(BaseClass, ColorMixin, ZCoordMixin) {}