get-prototype-descriptors

0.6.1 • Public • Published

get-prototype-descriptors

Build Status npm version Greenkeeper badge

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

Package Sidebar

Install

npm i get-prototype-descriptors

Weekly Downloads

40

Version

0.6.1

License

MIT

Unpacked Size

11.6 kB

Total Files

10

Last publish

Collaborators

  • taras