merge-light

0.0.2 • Public • Published

merge-light - npm

merge-light : merge objects into first argument object. thin merge copy.

PREPARE:

for node.js

$ npm install merge-light --save
var merge = require('merge-light');

or

for browsers

https://lightspeedworks.github.io/merge-light/merge-light.js

USAGE:

destination = merge(destination, source, ...)

EXAMPLES:

merge object into first object.

var merge = require('merge-light');
 
var a = {x:1};
var b = {y:2};
 
merge(a, b);
console.log(a);        // -> a = {x:1, y:2}
console.log(b);        // -> b = {y:2}

merge object into first object and return merged first object.

var merge = require('merge-light');
 
var a = {x:1};
var b = {y:2};
 
var c = merge(a, b);
console.log(a);        // -> a = {x:1, y:2}
console.log(b);        // -> b = {y:2}
console.log(c);        // -> c = {x:1, y:2}
console.log(=== c);  // -> true

create a new object and merge rest of arguments objects.

var merge = require('merge-light');
 
var a = {x:1};
var b = {y:2};
var c = {z:3};
 
var d = merge({}, a, b, c);
console.log(a);        // -> a = {x:1}
console.log(b);        // -> b = {y:2}
console.log(c);        // -> c = {z:3}
console.log(d);        // -> d = {x:1, y:2, z:3}

merge objects, if destination has same property already, then does not copied.

var merge = require('merge-light');
 
var a = {x:1, z:3};
var b = {y:22};
var c = {z:33};
var d = {w:44};
 
var e = merge({}, a, b, c, d);
console.log(a);        // -> a = {x:1, z:3}
console.log(b);        // -> b = {y:22}
console.log(c);        // -> c = {z:33}
console.log(d);        // -> d = {w:44}
console.log(e);        // -> d = {x:1, z:3, y:22, w:44}

LICENSE:

MIT

Readme

Keywords

Package Sidebar

Install

npm i merge-light

Weekly Downloads

18

Version

0.0.2

License

MIT

Last publish

Collaborators

  • lightspeedc