1.0.0 • Published 9 years ago

function-branch v1.0.0

Weekly downloads
1
License
MIT
Repository
github
Last release
9 years ago

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;

    };

});