JSPM

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

Make a progeny. This library supports many common inheritance related things

Package Exports

  • progenitor.js

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 (progenitor.js) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

progenitor.js

Circle CI
Build Status
npm version

#Getting started

###Install it

$ npm install progenitor.js

###Require it

var progenitor = require('progenitor.js');

###Use it

// To enable inheritance from Object and Error
Object.progeny = progenitor(Object);
Error.progeny = progenitor(Error);

then

BaseController = Object.progeny('BaseController', {
  // Instance methods
}, {
  classMethods: {
  }
});

The interface to inherit is progeny(newName, instanceMethods, options)

  • options can have a key classMethods that add methods to the class itself.
  • the class is accessible via this.class.
  • the special instance method init is called when during the process of returning a new object.
  • the special instance method this.super(functionName, *args) will call any super class instance method. (Note: it will not error if the method does not exist)
  • the special class method inherited is called during the process of generating a new derived class.