JSPM

pickapart

1.0.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 2
  • Score
    100M100P100Q14535F
  • License ISC

deep immutable destructuring with omit

Package Exports

  • pickapart

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (pickapart) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

pickapart NPM version Build Status Dependency Status Coverage percentage

deep immutable destructuring with omit

Installation

$ npm install --save pickapart

Usage

const pickapart = require('pickapart');

// pickapart(paths, source)
// * paths: String|Array (optional, if source is an Array)
// * source: Object|Array

const payload = { name: 'abc', meta: { token: 123, easy: true } };

const [token, data] = pickapart('meta.token', payload);
console.log('=> ', payload);
// => { name: 'abc', meta: { token: 123, easy: true }}
console.log('=> ', token);
// => 123
console.log('=> ', data);
// => { name: 'abc', meta: { easy: true }}

const [is, ez] = pickapart(['name', 'meta.easy'], payload);
console.log('=> ', is);
// => 'abc'
console.log('=> ', ez);
// => true

const flavors = ['chocolate', 'vanilla', 'strawberry'];

const [plain, others] = pickapart('[1]', flavors);
console.log('=> ', plain);
// => 'vanilla'
console.log('=> ', others);
// => [ 'chocolate', 'strawberry' ]

const [choco, notChoco] = pickapart(flavors);

console.log('=> ', choco);
// => 'chocolate'
console.log('=> ', notChoco);
// => [ 'vanilla', 'strawberry' ]

License

ISC © Buster Collings