Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F120570360
README.md
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Sat, Jul 5, 07:38
Size
1 KB
Mime Type
text/html
Expires
Mon, Jul 7, 07:38 (2 d)
Engine
blob
Format
Raw Data
Handle
27170909
Attached To
R8244 Eawag_Swing_Weight_Elicitation
README.md
View Options
# 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="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
```sh
npm test
```
Event Timeline
Log In to Comment