Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Expose merge routine.

  • Loading branch information...
commit 309aa2c3a880f0c72b5872c0c87ce950f461dab7 1 parent 42f297a
Corey Jewett authored October 24, 2011
3  lib/merge.js
@@ -41,6 +41,9 @@ function merge(a, b) {
41 41
     mergeProperty(a, b, prop);
42 42
   }
43 43
 
  44
+  // expose merge routine for reuse
  45
+  a._merge = function(b) { return merge(a, b); }
  46
+
44 47
   return a;
45 48
 };
46 49
 
10  tests/merge_test.js
@@ -48,4 +48,14 @@ test("b object property is merged with a object property", function(t) {
48 48
   t.type(result, "object");
49 49
   t.similar(result, {a:{c:3,d:5,e:6},b:2});
50 50
   t.end();
  51
+});
  52
+
  53
+test("object has merging capability", function(t) {
  54
+  var a = {a: 1, b: 2};
  55
+  var b = {a: 3};
  56
+  var result = merge(a, a);
  57
+  result = result._merge(b);
  58
+  t.type(result, "object");
  59
+  t.similar(result, {a:3, b:2});
  60
+  t.end();
51 61
 });

0 notes on commit 309aa2c

Please sign in to comment.
Something went wrong with that request. Please try again.