0.1.0 • Published 10 years ago

obj-c v0.1.0

Weekly downloads
2
License
MIT
Repository
github
Last release
10 years ago

Simple inherit helper with named constructor.

Installation

$ npm install obj-c

Example

var Obj = require('obj-c');

// copy of object class
var Base = Obj.create();

// with named constructor "function Model() { Base.apply(this, arguments) }"
var BaseModel = Base.create('Model', {
    foo: 'bar',
    baz: 'foo'
});

var Model = BaseModel.create(function Model() {
    BaseModel.apply(this, arguments); // constructor super call
    this.bar = 'baz';
    console.log(this.__constructor.name) // -> 'Model'
}, {
    foo: BaseModel.prototype.foo + '!',
);

var model = new Model;

model.foo; // -> 'foo!'
model.bar; // -> 'baz'
model.baz; // -> 'foo'

Running tests

$ make test

Authors

License

MIT

0.1.0

10 years ago

0.0.1

10 years ago