Prototypal(OLOO) inheritance algorithm.
Features
- Fully tested
- Fully documented
- OLOO ready
- Static & getter/setter inheritance
- Dynamic prototype & property swapping
- Supports symbols
- Validations for overrides, static this usage, illegal private usage
- Supports attributes! i.e. frozen, static, const etc.
- Supports amd, node, globals, es6 modules
- ES6 & ES5 binaries (as well as intermediate version)
- Made with bits of love!
Installation
bower install cell-type
npm install cell-type
Usage
const Beginner = ; const Specialist = ;// using the new keyword is also possibleconst Expert = name: 'Expert' links: Specialist properties: // an additional name can be supplied for debugging purposes this_x = 7; this; thisskills; return this return 'expert' get return this - 3 set this_x = this + 4 { "<$attrs static enumerable !configurable>"; // attributes can be used to supply additional functionality return this } staticProp: $attrs: 'static' value: 10; const e1 = Object; // default inheritance featuresto;tobetrue;tobetrue;tobetrue; // inheritance for getters/setterse1x = 4;todeep;todeep; // inheritance of static methodsto; // wrapping of static propertiese2 = Object;e1staticProp = 20;to;to; // using attributes to supply additional functionalitytobefalse; // by default enumerable is set to falsetobetrue; // by default configurable is set to truetobetrue; // using attributes this can be changedtobefalse; // using attributes this can be changed // validationstobetrue;
For more usage example see the unit tests @ /test/unit/Type-spec.js
Prototypal(OLOO) inheritance
By default prototypal(OLOO) inheritance is supported. Practically this means that types('classes') created by Type will just be simple objects that can be used as a prototype (no constructor function is supplied). In general I like to avoid any class related jargon. Therefore this._upper (instead of this._super) can be used to access a property higher up in the prototype chain. Statics will be directly available on the prototype. Static properties will be wrapped in a getter/setter so the value can be changed from this.
Documentation
Documentation can be generated by running the command below and is outputted @ /doc.
npm run docs
Make sure you'll run a npm install first.
Future work
- Traits (coming up in the near future)
- State properties
- Dependency injection (in some form or another)