allot

Utils for classes

npm install allot
1 downloads in the last day
1 downloads in the last week
26 downloads in the last month

Allot

A way of defining interfaces from one JavaScript class to a new class.

The idea is still a little abstract at the moment however its useful for building quick interfaces from one class to another.

Full documentation

Usage

allot.inherits

Classical inheritance to JavaScript, however methods are not copied or referenced they use the proxy methods defined in this module.


function SuperClass() {
};

SuperClass.thing = function () {
  return 'thing';
};

SuperClass.prototype.doSomething = function () {
  return 'Hello there';
};

var ChildClass = allot.inherits(function () {}, SuperClass);

ChildClass.thing();

var instance = new ChildClass();
instance.doSomething();

allot.factory

Builds a new class based upon SuperClass.

Static methods from instance methods


function SuperClass() {
};

SuperClass.prototype.doSomething = function () {
  return 'Hello there';
};

var ChildClass = allot.factory(SuperClass, {
  staticProxyPrototypes: ['doSomething']
});

ChildClass.doSomething();

var instance = new ChildClass();

Static methods from static methods


function SuperClass() {
};

SuperClass.doSomething = function () {
  return 'Hello there';
};

var ChildClass = allot.factory(SuperClass, {
  staticProxyMethods: ['doSomething']
});

ChildClass.doSomething();

var instance = new ChildClass();

Status

Build Status Coverage Status Dependency Status devDependency Status

Browser Support

Licence

Copyright (c) 2014 Jonathan Kingston

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with this program. If not, see http://www.gnu.org/licenses/.

npm loves you