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 3.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. # object.pick [![NPM version](https://img.shields.io/npm/v/object.pick.svg?style=flat)](https://www.npmjs.com/package/object.pick) [![NPM monthly downloads](https://img.shields.io/npm/dm/object.pick.svg?style=flat)](https://npmjs.org/package/object.pick) [![NPM total downloads](https://img.shields.io/npm/dt/object.pick.svg?style=flat)](https://npmjs.org/package/object.pick) [![Linux Build Status](https://img.shields.io/travis/jonschlinkert/object.pick.svg?style=flat&label=Travis)](https://travis-ci.org/jonschlinkert/object.pick)
  2. > Returns a filtered copy of an object with only the specified keys, similar to `_.pick` from lodash / underscore.
  3. You might also be interested in [object.omit](https://github.com/jonschlinkert/object.omit).
  4. ## Install
  5. Install with [npm](https://www.npmjs.com/):
  6. ```sh
  7. $ npm install --save object.pick
  8. ```
  9. ## benchmarks
  10. This is the [fastest implementation](http://jsperf.com/pick-props) I tested. Pull requests welcome!
  11. ## Usage
  12. ```js
  13. var pick = require('object.pick');
  14. pick({a: 'a', b: 'b'}, 'a')
  15. //=> {a: 'a'}
  16. pick({a: 'a', b: 'b', c: 'c'}, ['a', 'b'])
  17. //=> {a: 'a', b: 'b'}
  18. ```
  19. ## About
  20. ### Related projects
  21. * [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.")
  22. * [get-value](https://www.npmjs.com/package/get-value): Use property paths (`a.b.c`) to get a nested value from an object. | [homepage](https://github.com/jonschlinkert/get-value "Use property paths (`a.b.c`) to get a nested value from an object.")
  23. * [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.")
  24. * [set-value](https://www.npmjs.com/package/set-value): Create nested values and any intermediaries using dot notation (`'a.b.c'`) paths. | [homepage](https://github.com/jonschlinkert/set-value "Create nested values and any intermediaries using dot notation (`'a.b.c'`) paths.")
  25. ### Contributing
  26. Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).
  27. ### Building docs
  28. _(This document was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme) (a [verb](https://github.com/verbose/verb) generator), please don't edit the readme directly. Any changes to the readme must be made in [.verb.md](.verb.md).)_
  29. To generate the readme and API documentation with [verb](https://github.com/verbose/verb):
  30. ```sh
  31. $ npm install -g verb verb-generate-readme && verb
  32. ```
  33. ### Running tests
  34. Install dev dependencies:
  35. ```sh
  36. $ npm install -d && npm test
  37. ```
  38. ### Author
  39. **Jon Schlinkert**
  40. * [github/jonschlinkert](https://github.com/jonschlinkert)
  41. * [twitter/jonschlinkert](http://twitter.com/jonschlinkert)
  42. ### License
  43. Copyright © 2016, [Jon Schlinkert](https://github.com/jonschlinkert).
  44. Released under the [MIT license](https://github.com/jonschlinkert/object.pick/blob/master/LICENSE).
  45. ***
  46. _This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.2.0, on October 27, 2016._