Sha256: 49432266b483842f2c4aaaefb8742b55a39affff802171da998260e3fd16885a
Contents?: true
Size: 1.13 KB
Versions: 43
Compression:
Stored size: 1.13 KB
Contents
# 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 ```sh npm install merge --save ``` ```js 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 ```html <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 ```sh npm test ```
Version data entries
43 entries across 43 versions & 1 rubygems