1.0.1 • Published 5 years ago

assign-pick v1.0.1

Weekly downloads
3
License
MIT
Repository
github
Last release
5 years ago

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.

1.0.1

5 years ago

1.0.0

5 years ago