You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

README.md 2.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. # object.defaults [![NPM version](https://img.shields.io/npm/v/object.defaults.svg?style=flat)](https://www.npmjs.com/package/object.defaults) [![NPM monthly downloads](https://img.shields.io/npm/dm/object.defaults.svg?style=flat)](https://npmjs.org/package/object.defaults) [![NPM total downloads](https://img.shields.io/npm/dt/object.defaults.svg?style=flat)](https://npmjs.org/package/object.defaults) [![Linux Build Status](https://img.shields.io/travis/jonschlinkert/object.defaults.svg?style=flat&label=Travis)](https://travis-ci.org/jonschlinkert/object.defaults)
  2. > Like `extend` but only copies missing properties/values to the target object.
  3. ## Install
  4. Install with [npm](https://www.npmjs.com/):
  5. ```sh
  6. $ npm install --save object.defaults
  7. ```
  8. Install with [bower](https://bower.io/)
  9. ```sh
  10. $ bower install object.defaults --save
  11. ```
  12. ## Usage
  13. ```js
  14. var defaults = require('object.defaults');
  15. var obj = {a: 'c'};
  16. defaults(obj, {a: 'bbb', d: 'c'});
  17. console.log(obj);
  18. //=> {a: 'c', d: 'c'}
  19. ```
  20. Or immutable defaulting:
  21. ```js
  22. var defaults = require('object.defaults/immutable');
  23. var obj = {a: 'c'};
  24. var defaulted = defaults(obj, {a: 'bbb', d: 'c'});
  25. console.log(obj !== defaulted);
  26. //=> true
  27. ```
  28. ## About
  29. ### Contributing
  30. Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).
  31. ### Contributors
  32. | **Commits** | **Contributor** |
  33. | --- | --- |
  34. | 16 | [jonschlinkert](https://github.com/jonschlinkert) |
  35. | 1 | [phated](https://github.com/phated) |
  36. | 1 | [sobolevn](https://github.com/sobolevn) |
  37. ### Building docs
  38. _(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.)_
  39. To generate the readme, run the following command:
  40. ```sh
  41. $ npm install -g verbose/verb#dev verb-generate-readme && verb
  42. ```
  43. ### Running tests
  44. 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:
  45. ```sh
  46. $ npm install && npm test
  47. ```
  48. ### Author
  49. **Jon Schlinkert**
  50. * [github/jonschlinkert](https://github.com/jonschlinkert)
  51. * [twitter/jonschlinkert](https://twitter.com/jonschlinkert)
  52. ### License
  53. Copyright © 2017, [Jon Schlinkert](https://github.com/jonschlinkert).
  54. Released under the [MIT License](LICENSE).
  55. ***
  56. _This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.5.0, on April 26, 2017._