assign-map
v1.1.0
Published
Like Object.assign, but let you alter/delete some keys using functions
Downloads
1
Readme
assign-map
Like Object.assign, but let you alter/delete some keys using functions
Install
npm install --save assign-map
Usage
Simple One
assignMap({a:1, b:2}, {b: v=>v*2})
// {a:1, b:4}
Complex One
import assignMap from 'assign-map'
const newObject = assignMap(
{a:1,b:2},
{
a: value => ({c:3}),
x: (value, key) => ({x:value, k:key, d: 1234})
}
)
Result:
const expect = {
b: 2,
c: 3,
x: undefined,
k: 'x',
d: 1234
}
t.deepEqual(newObject, expect)