1.0.1 • Published 5 years ago
assign-pick v1.0.1
assign-pick
Like Object.assign
, but you can choose which keys get assigned to the target.
Usage
Signature
function assignPick(predicate: Array | (key, currentSource) => boolean, target: object, ...sources: object[]);
Example
// Using an Array to choose which keys will be assigned.
assignPick(['a', 'b'], {}, {a: 1, b: 2, c: 3});
// → { a: 1, b: 2 }; (c is ignored).
// Using a Function:
assignPick((key, curr) => key === 'a' || key === 'b', {}, {a: 1, b: 2, c: 3});
// → { a: 1, b: 2 }; (c is ignored).
License
This project is licensed under the MIT license. A copy of this license can be found here.