dprop

tiny util for making enumerable properties

  • dprop

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
dprop
601.0.09 years ago9 years agoMinified + gzip package size for dprop in KB

Readme

dprop
stable
Stupidly small utility for making enumerable and configurable getter/setter objects, because ES5 is annoying.
Before:
Object.defineProperties(obj, {
  foo: {
    configurable: true,
    enumerable: true,
    get: function() {
      return 'blah'
    }
  },
  bar: {
    configurable: true,
    enumerable: true,
    get: function() {
      return 'foobar'
    }
  }
})

After:
var getter = require('dprop')

Object.defineProperties(obj, {
  foo: getter(function() {
    return 'blah'
  }),
  bar: getter(function() {
    return 'foobar'
  })
})

Usage

NPM

dprop([get], [set])

Returns a { configurable: true, enumerable: true } object with the specified (optional) get and set functions.

See Also

  • d - a little more feature rich

License

MIT, see LICENSE.md for details.