Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
NodeJS Merge is used to merge multiple objects into one object.
JavaScript CSS
branch: master

v1.2.0

latest commit 6fc27c23e1
@yeikos authored
Failed to load latest commit information.
tests v1.2.0
.npmignore v1.1.3
LICENSE v1.1.3
README.md v1.2.0
bower.json v1.2.0
merge.js v1.2.0
merge.min.js v1.2.0
package.json v1.2.0

README.md

Merge

Merge multiple objects into one, optionally creating a new cloned object. Similar to the jQuery.extend but more flexible. Works in Node.js and the browser.

Node.js Usage

npm install merge --save
var merge = require('merge'), original, cloned;

console.log(merge({one:'hello'}, {two: 'world'}));
// -> {"one": "hello", "two": "world"}

original = { x: { y: 1 } };
cloned = merge(true, original);
cloned.x.y++;

console.log(original.x.y, cloned.x.y);
// -> 1, 2

console.log(merge.recursive(true, original, { x: { z: 2 } }));
// -> {"x": { "y": 1, "z": 2 } }

Browser Usage

<script src="http://files.yeikos.com/merge.js"></script>
<script>
    var original, cloned;

    console.log(merge({one:'hello'}, {two: 'world'}));
    // -> {"one": "hello", "two": "world"}

    original = { x: { y: 1 } };
    cloned = merge(true, original);
    cloned.x.y++;

    console.log(original.x.y, cloned.x.y);
    // -> 1, 2

    console.log(merge.recursive(true, original, { x: { z: 2 } }));
    // -> {"x": { "y": 1, "z": 2 } }

</script>

Tests

npm test
Something went wrong with that request. Please try again.