map-value
v1.1.1
Published
Map object key/value into new object, but let you alter/delete some keys using functions
Downloads
2
Readme
map-value
Map object key/value into new object, but let you alter/delete some keys using functions
Install
npm install --save map-value
Usage
Simple One
mapValue({a:1, b:2}, {b: v=>v*2})
// {a:1, b:4}
Complex One
const newObject = mapValue(
{a:1,b:2},
{
a: value => ({c:3}),
x: (value, key) => ({x:value, k:key, d: 1234})
}
)
Result:
{
b: 2,
c: 3,
x: undefined,
k: 'x',
d: 1234
}