Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

merging in jasondavies isEqual patch for wrapped objects.

  • Loading branch information...
commit 70d760f4f5855d2540ee498e332dc50a26fb1466 1 parent 85f1c77
Jeremy Ashkenas authored December 03, 2010
10  test/functions.js
@@ -70,13 +70,13 @@ $(document).ready(function() {
70 70
   asyncTest("functions: throttle", 1, function() {
71 71
     var counter = 0;
72 72
     var incr = function(){ counter++; };
73  
-    var throttledIncr = _.throttle(incr, 50);
  73
+    var throttledIncr = _.throttle(incr, 100);
74 74
     throttledIncr(); throttledIncr(); throttledIncr();
75  
-    setTimeout(throttledIncr, 60);
76  
-    setTimeout(throttledIncr, 70);
77  
-    setTimeout(throttledIncr, 110);
78 75
     setTimeout(throttledIncr, 120);
79  
-    _.delay(function(){ ok(counter == 3, "incr was throttled"); start(); }, 200);
  76
+    setTimeout(throttledIncr, 140);
  77
+    setTimeout(throttledIncr, 220);
  78
+    setTimeout(throttledIncr, 240);
  79
+    _.delay(function(){ ok(counter == 3, "incr was throttled"); start(); }, 400);
80 80
   });
81 81
 
82 82
   asyncTest("functions: debounce", 1, function() {
6  underscore.js
@@ -519,9 +519,6 @@
519 519
 
520 520
   // Perform a deep comparison to check if two objects are equal.
521 521
   _.isEqual = function(a, b) {
522  
-    // Unwrap any wrapped objects
523  
-    if (a && a._chain) a = a.value();
524  
-    if (b && b._chain) b = b.value();
525 522
     // Check object identity.
526 523
     if (a === b) return true;
527 524
     // Different types?
@@ -531,6 +528,9 @@
531 528
     if (a == b) return true;
532 529
     // One is falsy and the other truthy.
533 530
     if ((!a && b) || (a && !b)) return false;
  531
+    // Unwrap any wrapped objects
  532
+    if (a._chain) a = a.value();
  533
+    if (b._chain) b = b.value();
534 534
     // One of them implements an isEqual()?
535 535
     if (a.isEqual) return a.isEqual(b);
536 536
     // Check dates' integer values.

0 notes on commit 70d760f

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