function-branch
v1.0.0 class
function-branch v1.0.0
This is Function.prototype enhancement which enables developers to easily define classes in ES5 syntax.
Usage
// define plain old javascript class
var MyClass = Object.branch(function (pt) {
'use strict';
pt.myMethod = function () {...};
...
});
// inheritance
var MySubclass = MyClass.branch(function (pt) {
'use strict';
pt.myAnotherMethod = function () {
// ...
};
// ...
});
// call parent's method
// `super` means basically parent's prototype
var MySubclass = MyClass.branch(function (pt, super) {
'use strict';
pt.myMethod = function () {
var result = super.myMethod();
// ... do something ...
return result;
};
});
npm i function-branch
Metadata
- MIT
- Whatever
- Yoshiya Hinosawa
- released 1/25/2015