Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including poly-select with all npm packages installed. Try it out:

var polySelect = require("poly-select")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

poly-select v1.0.0

Pick selected properties from the given object or array


Picks given keys and associated values from an object or array


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)


  • Works with objects and arrays
  • Automatically curried


npm install poly-select


npm test


var select = require('poly-select');

var object = {
  a: 100,
  b: 200,
  c: 'blah, blah'

var array = [
  'blah, blah'

// Complete application
console.log(select(['a', 'c'], object)); // => { a: 100, c: 'blah, blah' }
console.log(select([0, 2], array)); // => [100, 'blah, blah']

// Partial application
var selectB = select('b');
console.log(selectB(object)); // => { b: 200 }

var select1 = select(1);
console.log(select1(array)); // => [200]


RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free