2.0.0 • Published 8 years ago

pickachu v2.0.0

Weekly downloads
-
License
ISC
Repository
-
Last release
8 years ago

Pickachu

const pick = require('pickachu')

// Sources are not transpiled by default
// So if you are using es5 environement, require the transpiled version :
var pick = require('pickachu/es5')


// Pickachu work like lodash _.pick but is always curried
const filter = pick([ 'a', 'b' ])
filter({ a:1, b:2, c:3 })
// => { a:1, b:2 }

// And it allows for deep path such as :
const filterDeep = pick([ 'a', 'c.a', 'c.b.a', 'c.b.b' ])
filterDeep({ a:1, b:2, c: { a: 3, b: { a: 4, b: 5, c: 6 }, c: 7 } })
// => { a:1, c: { a: 3, b: { a: 4, b: 5 } } }

Caveat : Do not play well if your keys contain dots.