-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from zeke/master
Housecleaning
- Loading branch information
Showing
2 changed files
with
62 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,50 @@ | ||
JavaScript/NodeJS Merge v1.1.3 | ||
================================================== | ||
# Merge | ||
|
||
What is it? | ||
-------------------------------------- | ||
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. | ||
|
||
JavaScript/NodeJS Merge is a tool to merge multiple objects into one object, with the possibility of create a new object cloned. His operation is very similar to the [jQuery.extend](http://api.jquery.com/jQuery.extend/) function but more flexible. | ||
## Node.js Usage | ||
|
||
Example from NodeJS | ||
-------------- | ||
```sh | ||
npm install merge --save | ||
``` | ||
|
||
var merge = require('merge'), // npm install -g merge | ||
original, cloned; | ||
|
||
console.log( | ||
merge({ one: 'hello' }, { two: 'world' }) | ||
```js | ||
var merge = require('merge'), original, cloned; | ||
|
||
); // {"one": "hello", "two": "world"} | ||
|
||
original = { x: { y: 1 } }; | ||
console.log(merge({one:'hello'}, {two: 'world'})); | ||
// -> {"one": "hello", "two": "world"} | ||
|
||
cloned = merge(true, original); | ||
original = { x: { y: 1 } }; | ||
cloned = merge(true, original); | ||
cloned.x.y++; | ||
|
||
console.log(original.x.y, cloned.x.y); | ||
// -> 1, 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 | ||
|
||
Example from JavaScript browser | ||
-------------------------- | ||
|
||
<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 | ||
|
||
</script> | ||
console.log(original.x.y, cloned.x.y); | ||
// -> 1, 2 | ||
</script> | ||
``` | ||
|
||
## Tests | ||
|
||
```sh | ||
npm test | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,23 @@ | ||
{ | ||
|
||
"name": "merge", | ||
"version": "1.1.3", | ||
"author": "yeikos (http://www.yeikos.com)", | ||
"description": "JavaScript/NodeJS Merge is a tool to merge multiple objects into one object, with the possibility of create a new object cloned. His operation is very similar to the jQuery.extend function but more flexible.", | ||
"main": "merge.js", | ||
"license": "MIT", | ||
"homepage": "https://github.com/yeikos/js.merge", | ||
|
||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/yeikos/js.merge.git" | ||
}, | ||
|
||
"keywords": [ | ||
"merge", | ||
"extend", | ||
"clone", | ||
"object", | ||
"browser" | ||
] | ||
|
||
"name": "merge", | ||
"version": "1.1.3", | ||
"author": "yeikos (http://www.yeikos.com)", | ||
"description": "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.", | ||
"main": "merge.js", | ||
"license": "MIT", | ||
"homepage": "https://github.com/yeikos/js.merge", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/yeikos/js.merge.git" | ||
}, | ||
"keywords": [ | ||
"merge", | ||
"extend", | ||
"clone", | ||
"object", | ||
"browser" | ||
], | ||
"scripts": { | ||
"test": "cd tests; node index.js" | ||
} | ||
} |