get-own-property-descriptors-polyfill

1.0.1 • Public • Published

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

Package Sidebar

Install

npm i get-own-property-descriptors-polyfill

Weekly Downloads

2,661

Version

1.0.1

License

MIT

Unpacked Size

4.02 kB

Total Files

4

Last publish

Collaborators

  • watson