inherits2

0.0.1 • Public • Published

inherits2

util.inherits with an extra argument to add properties.

function Person() {}
Person.prototype.getType = function() {
    return 'person';
};
 
Person.prototype.getName = function() {
    return 'joe';
};
 
function Ninja() {
    Person.apply(this, arguments);
}
 
inherits(Ninja, Person, {
    getType: function() {
        return 'ninja';
    }
});
 
var ninja = new Ninja();
 
assert.equal('joe', ninja.getName());
assert.equal('ninja', ninja.getType());
assert.equal('person', Ninja.super_.prototype.getType.call(ninja));

Readme

Keywords

Package Sidebar

Install

npm i inherits2

Weekly Downloads

0

Version

0.0.1

License

MIT

Last publish

Collaborators

  • jtangelder