get-own-property-descriptors-polyfill
Version:
A polyfill for Object.getOwnPropertyDescriptors
41 lines (28 loc) • 1.36 kB
Markdown
# get-own-property-descriptors-polyfill
A polyfill for
[`Object.getOwnPropertyDescriptors`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyDescriptors)
which wasn't included in Node.js until v7.0.0.
[](https://www.npmjs.com/package/get-own-property-descriptors-polyfill)
[](https://travis-ci.org/watson/get-own-property-descriptors-polyfill)
[](https://github.com/feross/standard)
## Installation
```
npm install get-own-property-descriptors-polyfill --save
```
## Usage
```js
const assert = require('assert')
const getOwnPropertyDescriptors = require('get-own-property-descriptors-polyfill')
function getter () { return 'hello' }
const obj = Object.defineProperties({}, {
foo: { value: 42, enumerable: false },
bar: { get: getter }
})
const descriptors = getOwnPropertyDescriptors(obj)
assert.deepStrictEqual(descriptors, {
foo: { value: 42, writable: false, enumerable: false, configurable: false },
bar: { get: getter, set: undefined, enumerable: false, configurable: false }
})
```
## License
[MIT](LICENSE)