Class factory featuring inheritance of static properties, static constructors, lazy population of prototypes, and this._super.
in ECMAScript 6, supposedly, but until then I need a class factory that fills the gap.
For me that means (in no particular order):
I have no delusions of persuading the world to use this tool. Just try
npm search inheritance some time to see how many other people have come
up with solutions that work for them.
Note that I did not mention privacy enforcement as a requirement. If you
need a mechanism like the
private keyword in other languages, I have a
separate project that works
seamlessly alongside this one.
npm install cls
cd path/to/node_modules git clone git://github.com/benjamn/cls.git cd cls npm install .
One example will have to suffice for now:
var cls = require"cls";var BaseClass = clsextendthissum = a + b;return thissum;statics:name: "BaseClass"clszero = 0 0;;var SubClass = BaseClassextendthis_superarg arg;thissum += 1;statics:name: "SubClass";assertBaseClassname === "BaseClass";assertSubClassname === "SubClass";assert2getSum === 4;assert2getSum === 5;assertSubClasszero !== BaseClasszero;assertSubClasszero instanceof SubClass;assertSubClasszerogetSum === 1;
For more complex examples, see