mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-08 02:17:48 +00:00
merging in jasondavies isEqual patch for wrapped objects.
This commit is contained in:
@@ -70,13 +70,13 @@ $(document).ready(function() {
|
|||||||
asyncTest("functions: throttle", 1, function() {
|
asyncTest("functions: throttle", 1, function() {
|
||||||
var counter = 0;
|
var counter = 0;
|
||||||
var incr = function(){ counter++; };
|
var incr = function(){ counter++; };
|
||||||
var throttledIncr = _.throttle(incr, 50);
|
var throttledIncr = _.throttle(incr, 100);
|
||||||
throttledIncr(); throttledIncr(); throttledIncr();
|
throttledIncr(); throttledIncr(); throttledIncr();
|
||||||
setTimeout(throttledIncr, 60);
|
|
||||||
setTimeout(throttledIncr, 70);
|
|
||||||
setTimeout(throttledIncr, 110);
|
|
||||||
setTimeout(throttledIncr, 120);
|
setTimeout(throttledIncr, 120);
|
||||||
_.delay(function(){ ok(counter == 3, "incr was throttled"); start(); }, 200);
|
setTimeout(throttledIncr, 140);
|
||||||
|
setTimeout(throttledIncr, 220);
|
||||||
|
setTimeout(throttledIncr, 240);
|
||||||
|
_.delay(function(){ ok(counter == 3, "incr was throttled"); start(); }, 400);
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest("functions: debounce", 1, function() {
|
asyncTest("functions: debounce", 1, function() {
|
||||||
|
|||||||
@@ -519,9 +519,6 @@
|
|||||||
|
|
||||||
// Perform a deep comparison to check if two objects are equal.
|
// Perform a deep comparison to check if two objects are equal.
|
||||||
_.isEqual = function(a, b) {
|
_.isEqual = function(a, b) {
|
||||||
// Unwrap any wrapped objects
|
|
||||||
if (a && a._chain) a = a.value();
|
|
||||||
if (b && b._chain) b = b.value();
|
|
||||||
// Check object identity.
|
// Check object identity.
|
||||||
if (a === b) return true;
|
if (a === b) return true;
|
||||||
// Different types?
|
// Different types?
|
||||||
@@ -531,6 +528,9 @@
|
|||||||
if (a == b) return true;
|
if (a == b) return true;
|
||||||
// One is falsy and the other truthy.
|
// One is falsy and the other truthy.
|
||||||
if ((!a && b) || (a && !b)) return false;
|
if ((!a && b) || (a && !b)) return false;
|
||||||
|
// Unwrap any wrapped objects
|
||||||
|
if (a._chain) a = a.value();
|
||||||
|
if (b._chain) b = b.value();
|
||||||
// One of them implements an isEqual()?
|
// One of them implements an isEqual()?
|
||||||
if (a.isEqual) return a.isEqual(b);
|
if (a.isEqual) return a.isEqual(b);
|
||||||
// Check dates' integer values.
|
// Check dates' integer values.
|
||||||
|
|||||||
Reference in New Issue
Block a user