function-branch

1.0.0 • Public • Published

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;
 
    };
 
});

Readme

Keywords

Package Sidebar

Install

npm i function-branch

Weekly Downloads

1

Version

1.0.0

License

MIT

Last publish

Collaborators

  • kt3k