dc319b7cf5caa26acd60e2305292761a2975fe58ecdc012000bbc505c1acc52eb575cd3361bccc623668feeffc95f5de221b79a1b923b4a8394578c79ef79d 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. # define-property [![NPM version](https://badge.fury.io/js/define-property.svg)](http://badge.fury.io/js/define-property)
  2. > Define a non-enumerable property on an object.
  3. ## Install
  4. Install with [npm](https://www.npmjs.com/)
  5. ```sh
  6. $ npm i define-property --save
  7. ```
  8. ## Usage
  9. **Params**
  10. * `obj`: The object on which to define the property.
  11. * `prop`: The name of the property to be defined or modified.
  12. * `descriptor`: The descriptor for the property being defined or modified.
  13. ```js
  14. var define = require('define-property');
  15. var obj = {};
  16. define(obj, 'foo', function(val) {
  17. return val.toUpperCase();
  18. });
  19. console.log(obj);
  20. //=> {}
  21. console.log(obj.foo('bar'));
  22. //=> 'BAR'
  23. ```
  24. **get/set**
  25. ```js
  26. define(obj, 'foo', {
  27. get: function() {},
  28. set: function() {}
  29. });
  30. ```
  31. ## Related projects
  32. * [delegate-object](https://www.npmjs.com/package/delegate-object): Copy properties from an object to another object, where properties with function values will be… [more](https://www.npmjs.com/package/delegate-object) | [homepage](https://github.com/doowb/delegate-object)
  33. * [forward-object](https://www.npmjs.com/package/forward-object): Copy properties from an object to another object, where properties with function values will be… [more](https://www.npmjs.com/package/forward-object) | [homepage](https://github.com/doowb/forward-object)
  34. * [mixin-deep](https://www.npmjs.com/package/mixin-deep): Deeply mix the properties of objects into the first object. Like merge-deep, but doesn't clone. | [homepage](https://github.com/jonschlinkert/mixin-deep)
  35. * [mixin-object](https://www.npmjs.com/package/mixin-object): Mixin the own and inherited properties of other objects onto the first object. Pass an… [more](https://www.npmjs.com/package/mixin-object) | [homepage](https://github.com/jonschlinkert/mixin-object)
  36. ## Running tests
  37. Install dev dependencies:
  38. ```sh
  39. $ npm i -d && npm test
  40. ```
  41. ## Contributing
  42. Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/jonschlinkert/define-property/issues/new).
  43. ## Author
  44. **Jon Schlinkert**
  45. + [github/jonschlinkert](https://github.com/jonschlinkert)
  46. + [twitter/jonschlinkert](http://twitter.com/jonschlinkert)
  47. ## License
  48. Copyright © 2015 Jon Schlinkert
  49. Released under the MIT license.
  50. ***
  51. _This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on August 31, 2015._