collect-property
v0.1.1
Published
Collect property over prototype chain
Downloads
6
Readme
collect-property
Collect property over prototype chain.
Install
Download manually or with package-manager.
npm
npm install --save collect-property
Example
var collectProperty = require('collect-property');
// Define constructors with following hierarchy: C -> B -> A
var A = function () {
this.prop = 'baz';
};
var B = function () {
this.prop = 'bar';
};
B.prototype = new A();
var C = function () {
this.prop = 'foo';
};
C.prototype = new B();
// Create an instance.
var o = new C();
// Collect all values for the `prop` property.
var values = collectProperty(o, 'prop');
// → ['foo', 'bar', 'baz']
Contributions
Contributions are very welcomed, either on the documentation or on the code.
You may:
- report any issue you've encountered;
- fork and create a pull request.
License
ISC © Julien Fontanet