5f05b0c1a8ef5bcd4d56c0a5d2c908e2b87c110c9c0ffccbc21eb5f6776e4655d1bfa7bdf66060d0a84ff03697cfd490dba14455b4ebe555e84b40d8a18ad9 3.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. # define-property [![NPM version](https://img.shields.io/npm/v/define-property.svg?style=flat)](https://www.npmjs.com/package/define-property) [![NPM monthly downloads](https://img.shields.io/npm/dm/define-property.svg?style=flat)](https://npmjs.org/package/define-property) [![NPM total downloads](https://img.shields.io/npm/dt/define-property.svg?style=flat)](https://npmjs.org/package/define-property) [![Linux Build Status](https://img.shields.io/travis/jonschlinkert/define-property.svg?style=flat&label=Travis)](https://travis-ci.org/jonschlinkert/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 install --save define-property
  7. ```
  8. Install with [yarn](https://yarnpkg.com):
  9. ```sh
  10. $ yarn add define-property
  11. ```
  12. ## Usage
  13. **Params**
  14. * `obj`: The object on which to define the property.
  15. * `prop`: The name of the property to be defined or modified.
  16. * `descriptor`: The descriptor for the property being defined or modified.
  17. ```js
  18. var define = require('define-property');
  19. var obj = {};
  20. define(obj, 'foo', function(val) {
  21. return val.toUpperCase();
  22. });
  23. console.log(obj);
  24. //=> {}
  25. console.log(obj.foo('bar'));
  26. //=> 'BAR'
  27. ```
  28. **get/set**
  29. ```js
  30. define(obj, 'foo', {
  31. get: function() {},
  32. set: function() {}
  33. });
  34. ```
  35. ## About
  36. ### Related projects
  37. * [assign-deep](https://www.npmjs.com/package/assign-deep): Deeply assign the enumerable properties and/or es6 Symbol properies of source objects to the target… [more](https://github.com/jonschlinkert/assign-deep) | [homepage](https://github.com/jonschlinkert/assign-deep "Deeply assign the enumerable properties and/or es6 Symbol properies of source objects to the target (first) object.")
  38. * [extend-shallow](https://www.npmjs.com/package/extend-shallow): Extend an object with the properties of additional objects. node.js/javascript util. | [homepage](https://github.com/jonschlinkert/extend-shallow "Extend an object with the properties of additional objects. node.js/javascript util.")
  39. * [merge-deep](https://www.npmjs.com/package/merge-deep): Recursively merge values in a javascript object. | [homepage](https://github.com/jonschlinkert/merge-deep "Recursively merge values in a javascript object.")
  40. * [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 "Deeply mix the properties of objects into the first object. Like merge-deep, but doesn't clone.")
  41. ### Contributing
  42. Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).
  43. ### Building docs
  44. _(This project's readme.md is generated by [verb](https://github.com/verbose/verb-generate-readme), please don't edit the readme directly. Any changes to the readme must be made in the [.verb.md](.verb.md) readme template.)_
  45. To generate the readme, run the following command:
  46. ```sh
  47. $ npm install -g verbose/verb#dev verb-generate-readme && verb
  48. ```
  49. ### Running tests
  50. Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:
  51. ```sh
  52. $ npm install && npm test
  53. ```
  54. ### Author
  55. **Jon Schlinkert**
  56. * [github/jonschlinkert](https://github.com/jonschlinkert)
  57. * [twitter/jonschlinkert](https://twitter.com/jonschlinkert)
  58. ### License
  59. Copyright © 2017, [Jon Schlinkert](https://github.com/jonschlinkert).
  60. Released under the [MIT License](LICENSE).
  61. ***
  62. _This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.5.0, on April 20, 2017._