1.0.1 • Published 5 years ago

get-own-property-descriptors-polyfill v1.0.1

Weekly downloads
8,867
License
MIT
Repository
github
Last release
5 years ago

get-own-property-descriptors-polyfill

A polyfill for Object.getOwnPropertyDescriptors which wasn't included in Node.js until v7.0.0.

npm build status js-standard-style

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 }
})

License

MIT