Make _.where search arrays for values.

Former-commit-id: b942c6a44680c78fae1a41f2cf994be09ffcfbb9
This commit is contained in:
John-David Dalton
2013-02-16 00:39:45 -08:00
parent 9ccfa5cec9
commit 2a2bc44f43
7 changed files with 181 additions and 140 deletions

View File

@@ -1568,16 +1568,27 @@
// recursively compare objects and arrays (susceptible to call stack limits)
if (isArr) {
// compare lengths to determine if a deep comparison is necessary
length = a.length;
size = b.length;
result = whereIndicator || size == a.length;
if (result) {
// deep compare the contents, ignoring non-numeric properties
while (size--) {
if (!(result = isEqual(a[size], b[size], callback, thisArg, stackA, stackB))) {
break;
// compare lengths to determine if a deep comparison is necessary
result = size == a.length;
if (!result && !whereIndicator) {
return result;
}
// deep compare the contents, ignoring non-numeric properties
while (size--) {
var index = length,
value = b[size];
if (whereIndicator) {
while (index--) {
if ((result = isEqual(a[index], value, callback, thisArg, stackA, stackB))) {
break;
}
}
} else if (!(result = isEqual(a[size], value, callback, thisArg, stackA, stackB))) {
break;
}
}
return result;