0.0.2 • Published 10 years ago

collect-over-prototype v0.0.2

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

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' });
});