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.
Last updated 2 years ago by yeikos .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install merge 
SYNC missed versions from official npm registry.

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="https://cdn.jsdelivr.net/gh/yeikos/js.merge/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

Current Tags

  • 1.2.1                                ...           latest (2 years ago)

7 Versions

  • 1.2.1                                ...           2 years ago
  • 1.2.0                                ...           6 years ago
  • 1.1.3                                ...           6 years ago
  • 1.1.2                                ...           7 years ago
  • 1.1.1                                ...           7 years ago
  • 1.1.0                                ...           7 years ago
  • 1.0.0                                ...           8 years ago
Maintainers (1)
Downloads
Today 8,934
This Week 36,598
This Month 69,886
Last Day 9,314
Last Week 50,898
Last Month 221,150
Dependencies (0)
None
Dev Dependencies (0)
None
Dependents (1901)

Copyright 2014 - 2016 © taobao.org |