unionj
v1.0.0
Published
Unify JSON documents
Downloads
9
Readme
Unionj
Unify JSON documents
Install
$ npm install --save unionj
Usage
var obj1 = { 'k1': 'v1a' };
var obj2 = { 'k1': 'v1b' };
var unionj = require('unionj');
var result = unionj.add(obj1, obj2);
console.log(result.k1); // v1b
Rules
There are only two rules that drive the merge process:
- "Simple addition" rule: if a field is in one of the documents but not in the other one then that field will be in the resulting doc and get the value it holds in the doc it appears in
- "Second-over-first" rule: if a field is in both documents it will be in the resulting doc and get the value it holds in the second one
License
MIT © Nicola Orritos