An object prototype building framework

npm install base-framework
4 downloads in the last day
12 downloads in the last week
24 downloads in the last month

The summary

Base is a lightweight framework for creating consistent, highly readable, chainable and inheritable object prototypes in Javascript. This git repo is for an NPM module for use with Node. It can be used in the browser so long as you manually satisfy the Underscore dependency. You're already using Underscore though, anyway, right?

The detail


// Require base...
var base = require('base');

// create a base child. Add the default 'init' constructor which is
// executed automatically when the object is invoked, and another 
// instance method.

var MyFactory = base.createChild()
        init : function( args ){
            this.args = args;
            return this;
        spewArgs : function(){

var myInstance = MyFactory({ hello : 'world'}).spewArgs() // outputs {hello : 'world'} to the console

Objects created with base.createChild() have a number of static methods which are used to build your factory.


var Foo = base.createChild();

    secretOfLifeUniverseAndEverything : function(){
        return 42;

Foo.secretOfLifeTheUniverseAndEverything() === 42 // TRUE
npm loves you