Skip to main content
Module

x/rambda/pick.js

Faster and smaller alternative to Ramda
Go to Latest
File
export function pick(propsToPick, input){ if (arguments.length === 1) return _input => pick(propsToPick, _input)
if (input === null || input === undefined){ return undefined } const keys = typeof propsToPick === 'string' ? propsToPick.split(',') : propsToPick
const willReturn = {} let counter = 0
while (counter < keys.length){ if (keys[ counter ] in input){ willReturn[ keys[ counter ] ] = input[ keys[ counter ] ] } counter++ }
return willReturn}