get-own-property-descriptors-polyfill
v1.0.1
Published
A polyfill for Object.getOwnPropertyDescriptors
Downloads
10,211
Maintainers
Readme
get-own-property-descriptors-polyfill
A polyfill for
Object.getOwnPropertyDescriptors
which wasn't included in Node.js until v7.0.0.
Installation
npm install get-own-property-descriptors-polyfill --save
Usage
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 }
})