collect-over-prototype

0.0.2 • Public • Published

Collects an object key over an object's prototype chain.

test('can collect an object key over prototype chain and self', function(t) {
    t.plan(1);
    var A = function() { this.someKey = { big: 'smells' }; };
    var B = function() { this.someKey = { awesome: 'fish' }; };
    var C = function() { this.someKey = { swims: 'fast' }; };
    B.prototype = new A;
    C.prototype = new B;

    var c = new C;
    var collected = collectOverPrototype(c, 'someKey', true);
    t.deepEqual(collected, { big: 'smells', awesome: 'fish', swims: 'fast' });
});

Readme

Keywords

none

Package Sidebar

Install

npm i collect-over-prototype

Weekly Downloads

1

Version

0.0.2

License

MIT

Last publish

Collaborators

  • dminkovsky