Nice Paintings, Mondrian
Unleash awesomeness. Private packages, team management tools, and powerful integrations. Get started with npm Orgs »

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

Keywords

install

npm i function-branch

Downloadsweekly downloads

1

version

1.0.0

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability