Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

pick-deep

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pick-deep

Creates an object composed of the picked object properties from a nested object using a dot path or custom separator

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2.9K
decreased by-17.24%
Maintainers
1
Weekly downloads
 
Created
Source

pick-deep License npm

Build Status node Test Coverage bitHound Score

One of the smallest (28 sloc) and most effective implementations of object properties deep picking.

Usage

$ npm install pick-deep --save
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.
  • @strikeentco/get - One of the smallest and most effective implementations of getting a nested value from an object.
  • @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

Keywords

FAQs

Package last updated on 19 Mar 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc