obj-c

0.1.0 • Public • Published

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

/obj-c/

    Package Sidebar

    Install

    npm i obj-c

    Weekly Downloads

    0

    Version

    0.1.0

    License

    MIT

    Last publish

    Collaborators

    • fi11