shallow-pick
A utility function similar to pick()
in underscore
or lo-dash
.
{/*...*/}
Creates an object constructed of all specified properties of source leaving source itself untouched. Returns shallow partial clone of source
Makes only a shallow copy of the source feilds, consider using it with node-extend or node-deep-extend if a deep copy desired.
Examples
Picking only existing properties:
var source = a: 1 b: 2 c: 3; var destination = ;// destination --> {a: 1, c: 3}// source --> {a: 1, b: 2, c: 3}
Sanitizing input parameters with pick and extend:
{ return ;} var input = ;// input --> {a: 'something', b: 'default value'}