get-descriptor

1.0.1 • Public • Published

get-descriptor

Taking the 'own' out of Object.getOwnPropertyDescriptor.

Build Status

Same as Object.getOwnPropertyDescriptor except it searches the prototype chain to find the descriptor.

Installation

npm install get-descriptor

Example

var getDescriptor = require('get-descriptor')
 
var proto = {}
 
Object.defineProperty(proto, 'value', {
  value: 'hello',
  configurable: false,
  enumerable: false,
  writable: false
})
 
var obj = Object.create(proto)
 
// finds 'value' descriptor on prototype chain :D
getDescriptor(obj, 'value'), descriptor) // => { configurable: false, enumerable: false, value: 'hello', writable: false }
 
// without getDescriptor
Object.getOwnPropertyDescriptor(obj, 'value') // => null

License

MIT

Package Sidebar

Install

npm i get-descriptor

Weekly Downloads

1

Version

1.0.1

License

MIT

Last publish

Collaborators

  • timoxley