get-prototype-descriptors
v0.6.1
Published
Gather descriptors from constructor's prototype chain
Downloads
89
Readme
get-prototype-descriptors
Returns all descriptors of a prototype chain while respecting prototype inheritance.
Installation
npm install --save get-prototype-descriptors
Usage
class A {
one() {}
get getterOnA() {
return 'A';
}
}
class B extends A {
two() {}
get getterOnA() {
return 'B';
}
}
class C extends B {
three() {}
get getterOnC() {
return 'C'
}
}
import getPrototypeDescriptors from 'get-prototype-descriptors';
let descriptors = getPrototypeDescriptors(C);
The descriptors will be flattened and descriptors from child classes will overload those of the parent.
Compatibility
get-prototype-descriptors
requires Object.getOwnPropertyDescriptors
which is not available in IE and pre-Node 6.
You may consider adding a polyfill if you need to support these environments.
License
MIT License