unionj

1.0.0 • Public • Published

NPM version Dependency Status

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

Readme

Keywords

Package Sidebar

Install

npm i unionj

Weekly Downloads

2

Version

1.0.0

License

MIT

Last publish

Collaborators

  • nicolaorritos