union-merge
v1.0.3
Published
union merge
Downloads
2
Readme
union-merge
Deeply merging unstructured data.
Installation
npm i union-merge -S
usage
const unionMerge = require('union-merge');
let target = {
name: 'Tom',
age: '30',
orders: [
{orderId: 20180104, price: 200, title: 'a', phone: 1234},
{orderId: 20180105, price: 200, title: 'a'}
]
};
let source = {
name: 'Tom',
age: 31,
orders: [
{orderId: 20180104, price: 200, title: 'a'},
{orderId: 20180105, price: 220, title: 'a', phone: 1234, email: '[email protected]'},
{orderId: 20180106, price: 200, title: 'a'},
{orderId: 20180107, price: 200, title: 'a', phone: 1234},
]
};
let result = unionMerge(target, source, ['orderId']);
/*
{
name: 'Tom',
age: 31,
orders: [
{orderId: 20180104, price: 200, title: 'a', phone: 1234},
{orderId: 20180105, price: 220, title: 'a', phone: 1234, email: '[email protected]'},
{orderId: 20180106, price: 200, title: 'a'},
{orderId: 20180107, price: 200, title: 'a', phone: 1234},
]
}
*/
Tests
no scripts
Contributing
...