https://github.com/strikeentco/pick-deep
Creates an object composed of the picked object properties from a nested object using a dot path or custom separator
https://github.com/strikeentco/pick-deep
deep dot dot-path dot-prop fast javascript lodash lodash-pick nested-value nodejs object object-path path pick pick-deep small
Last synced: about 1 month ago
JSON representation
Creates an object composed of the picked object properties from a nested object using a dot path or custom separator
- Host: GitHub
- URL: https://github.com/strikeentco/pick-deep
- Owner: strikeentco
- License: mit
- Created: 2018-03-19T16:27:43.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2018-03-19T16:39:58.000Z (about 7 years ago)
- Last Synced: 2025-04-14T01:54:15.322Z (about 1 month ago)
- Topics: deep, dot, dot-path, dot-prop, fast, javascript, lodash, lodash-pick, nested-value, nodejs, object, object-path, path, pick, pick-deep, small
- Language: JavaScript
- Homepage:
- Size: 41 KB
- Stars: 9
- Watchers: 1
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
pick-deep [](https://github.com/strikeentco/pick-deep/blob/master/LICENSE) [](https://www.npmjs.com/package/pick-deep)
==========
[](https://travis-ci.org/strikeentco/pick-deep) [](https://www.npmjs.com/package/pick-deep) [](https://codeclimate.com/github/strikeentco/pick-deep/test_coverage) [](https://www.bithound.io/github/strikeentco/pick-deep)One of the smallest (*28 sloc*) and most effective implementations of object properties deep picking.
# Usage
```sh
$ npm install pick-deep --save
``````javascript
const pick = require('pick-deep');pick({ a: { b: ['c', 'd'], e: 'f' } }, 'a.b');
pick({ a: { b: ['c', 'd'], e: 'f' } }, ['a.b']);
pick({ a: { b: ['c', 'd'], e: 'f' } }, [['a', 'b']]);
//=> { a: { b: ['c', 'd'] } }pick({ a: { b: ['c', 'd'], e: 'f' }, j: { k: 'l' }, q: { r: ['s', 't'], u: 'w' }}, [['a', 'b'], 'j', 'q.u']);
//=> { a: { b: ['c', 'd'] }, j: { k: 'l' }, q: { u: 'w' }}pick({ a: { b: 'c' } }, 'a.b.c.d');
//=> {}pick({ a: { b: 'c' } }, 'a:b', ':');
//=> { a: { b: 'c' } }
```
## API### pick(obj, paths, [separator])
#### Params:
* **obj** (*Object*) - Source object.
* **paths** (*String|Array|Array of Arrays*) - String, array or array of arrays with paths.
* **[separator]** (*String*) - `.` by default.## Related
- [@strikeentco/get](https://github.com/strikeentco/get) - One of the smallest and most effective implementations of getting a nested value from an object.
- [@strikeentco/set](https://github.com/strikeentco/set) - One of the smallest and most effective implementations of setting a nested value on an object.## License
The MIT License (MIT)
Copyright (c) 2018 Alexey Bystrov