Skip to content

gushov/lilobj

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

lilobj

A li'l object inheritance sugar.

Documentation

[obj|arr].extends(properties)

Returns new object with the prototype of the caller and the given properties.

instance.creates(args...)

Returns new object with the prototype of the caller and invokes the construct method with args

instance.isA(prototype)

returns true if the caller has the given prototype

Browser usage

load dist/lilobj.js or dist/lilobj.min.js in you browser and call it like this:

(function () {

  var lilobj = require('lilobj');

  var beer = lilobj.obj.extend({
    construct: function (hops, malt, yeast) {
      this.hops = hops;
      this.malt = malt;
      this.yeast = yeast; 
    }
  });

  var ale = beer.create('cascade', 'two-row', 1056);

  //returns true
  ale.isA(beer)

}());

Node usage

Install via npm: npm install lilobj

var lilobj = require('lilobj');

var beer = lilobj.obj.extend({
  construct: function (hops, malt, yeast) {
    this.hops = hops;
    this.malt = malt;
    this.yeast = yeast; 
  }
});

var ale = beer.create('cascade', 'two-row', 1056);

//returns true
ale.isA(beer)

License

Copyright (c) 2012 August Hovland Licensed under the MIT license.

About

A li'l object inheritance sugar.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages