Permalink
Browse files

documentation and an example

  • Loading branch information...
1 parent d0fce9a commit 5970d95e867fc6a00da5351e9230a9d0d9a7fc54 @substack committed Mar 29, 2012
Showing with 60 additions and 0 deletions.
  1. +55 −0 README.markdown
  2. +5 −0 example/merge.js
View
55 README.markdown
@@ -0,0 +1,55 @@
+deepmerge
+=========
+
+Merge the enumerable attributes of two objects deeply.
+
+example
+=======
+
+``` js
+var merge = require('deepmerge')
+var x = { foo : { 'bar' : 3 } }
+var y = { foo : { 'baz' : 4 }, quux : 5 }
+var merged = merge(x, y)
+console.dir(merged)
+```
+
+output:
+
+```
+{ foo: { bar: 3, baz: 4 }, quux: 5 }
+```
+
+methods
+=======
+
+var merge = require('deepmerge')
+
+merge(x, y)
+-----------
+
+Merge two objects `x` and `y` deeply, returning a new merged object with the
+elements from both `x` and `y`.
+
+If an element at the same key is present for both `x` and `y`, the value from
+`y` will appear in the result.
+
+The merge is immutable, so neither `x` nor `y` will be modified.
+
+install
+=======
+
+With [npm](http://npmjs.org) do:
+
+```
+npm install deepmerge
+```
+
+test
+====
+
+With [npm](http://npmjs.org) do:
+
+```
+npm test
+```
View
5 example/merge.js
@@ -0,0 +1,5 @@
+var merge = require('../')
+var x = { foo : { 'bar' : 3 } }
+var y = { foo : { 'baz' : 4 }, quux : 5 }
+var merged = merge(x, y)
+console.dir(merged)

0 comments on commit 5970d95

Please sign in to comment.