poly-select
Picks given keys and associated values from an object or array
Motivation
When working data transformation pipelines, it is often needed to be able to filter out unused data leaving only a few pieces for downstream processing.
This tool is effectively a shorthand version of:
filter((x, key) => selectedKeys.indexOf(key) >= 0)
Features
- Works with objects and arrays
- Automatically curried
Installation
npm install poly-select
Testing
npm test
Usage
var select = ; var object = a: 100 b: 200 c: 'blah, blah'; var array = 100 200 'blah, blah'; // Complete applicationconsole; // => { a: 100, c: 'blah, blah' }console; // => [100, 'blah, blah'] // Partial applicationvar selectB = ;console; // => { b: 200 } var select1 = ;console; // => [200]