1 |
3a515b92
|
cagy
|
# object.pick [](https://www.npmjs.com/package/object.pick) [](https://npmjs.org/package/object.pick) [](https://npmjs.org/package/object.pick) [](https://travis-ci.org/jonschlinkert/object.pick)
|
2 |
|
|
|
3 |
|
|
> Returns a filtered copy of an object with only the specified keys, similar to `_.pick` from lodash / underscore.
|
4 |
|
|
|
5 |
|
|
You might also be interested in [object.omit](https://github.com/jonschlinkert/object.omit).
|
6 |
|
|
|
7 |
|
|
## Install
|
8 |
|
|
|
9 |
|
|
Install with [npm](https://www.npmjs.com/):
|
10 |
|
|
|
11 |
|
|
```sh
|
12 |
|
|
$ npm install --save object.pick
|
13 |
|
|
```
|
14 |
|
|
|
15 |
|
|
## benchmarks
|
16 |
|
|
|
17 |
|
|
This is the [fastest implementation](http://jsperf.com/pick-props) I tested. Pull requests welcome!
|
18 |
|
|
|
19 |
|
|
## Usage
|
20 |
|
|
|
21 |
|
|
```js
|
22 |
|
|
var pick = require('object.pick');
|
23 |
|
|
|
24 |
|
|
pick({a: 'a', b: 'b'}, 'a')
|
25 |
|
|
//=> {a: 'a'}
|
26 |
|
|
|
27 |
|
|
pick({a: 'a', b: 'b', c: 'c'}, ['a', 'b'])
|
28 |
|
|
//=> {a: 'a', b: 'b'}
|
29 |
|
|
```
|
30 |
|
|
|
31 |
|
|
## About
|
32 |
|
|
|
33 |
|
|
### Related projects
|
34 |
|
|
|
35 |
|
|
* [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.")
|
36 |
|
|
* [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.")
|
37 |
|
|
* [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.")
|
38 |
|
|
* [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.")
|
39 |
|
|
|
40 |
|
|
### Contributing
|
41 |
|
|
|
42 |
|
|
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).
|
43 |
|
|
|
44 |
|
|
### Building docs
|
45 |
|
|
|
46 |
|
|
_(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).)_
|
47 |
|
|
|
48 |
|
|
To generate the readme and API documentation with [verb](https://github.com/verbose/verb):
|
49 |
|
|
|
50 |
|
|
```sh
|
51 |
|
|
$ npm install -g verb verb-generate-readme && verb
|
52 |
|
|
```
|
53 |
|
|
|
54 |
|
|
### Running tests
|
55 |
|
|
|
56 |
|
|
Install dev dependencies:
|
57 |
|
|
|
58 |
|
|
```sh
|
59 |
|
|
$ npm install -d && npm test
|
60 |
|
|
```
|
61 |
|
|
|
62 |
|
|
### Author
|
63 |
|
|
|
64 |
|
|
**Jon Schlinkert**
|
65 |
|
|
|
66 |
|
|
* [github/jonschlinkert](https://github.com/jonschlinkert)
|
67 |
|
|
* [twitter/jonschlinkert](http://twitter.com/jonschlinkert)
|
68 |
|
|
|
69 |
|
|
### License
|
70 |
|
|
|
71 |
|
|
Copyright © 2016, [Jon Schlinkert](https://github.com/jonschlinkert).
|
72 |
|
|
Released under the [MIT license](https://github.com/jonschlinkert/object.pick/blob/master/LICENSE).
|
73 |
|
|
|
74 |
|
|
***
|
75 |
|
|
|
76 |
|
|
_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.2.0, on October 27, 2016._
|