collect-over-prototype
v0.0.2
Published
Collect a property over the prototype chain
Downloads
2
Readme
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' });
});