mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-01-31 23:37:49 +00:00
Ignore isSorted if _.indexOf is customized.
This commit is contained in:
@@ -2397,11 +2397,12 @@
|
||||
}
|
||||
var index = -1,
|
||||
indexOf = getIndexOf(),
|
||||
prereq = !isSorted && indexOf === baseIndexOf,
|
||||
prereq = indexOf === baseIndexOf,
|
||||
isLarge = prereq && createCache && length >= 200,
|
||||
isCommon = prereq && !isLarge,
|
||||
result = [];
|
||||
|
||||
isSorted = prereq && isSorted;
|
||||
if (isLarge) {
|
||||
var seen = createCache();
|
||||
indexOf = cacheIndexOf;
|
||||
|
||||
10
test/test.js
10
test/test.js
@@ -4527,11 +4527,15 @@
|
||||
}
|
||||
});
|
||||
|
||||
test('`_.uniq` should work with a custom `_.indexOf` method', 2, function() {
|
||||
test('`_.uniq` should work with a custom `_.indexOf` method', 6, function() {
|
||||
if (!isModularize) {
|
||||
_.indexOf = custom;
|
||||
deepEqual(_.uniq(array), array.slice(0, 3));
|
||||
deepEqual(_.uniq(largeArray), [largeArray[0]]);
|
||||
|
||||
_.each([false, true, _.identity], function(param) {
|
||||
deepEqual(_.uniq(array, param), array.slice(0, 3));
|
||||
deepEqual(_.uniq(largeArray, param), [largeArray[0]]);
|
||||
});
|
||||
|
||||
_.indexOf = indexOf;
|
||||
}
|
||||
else {
|
||||
|
||||
Reference in New Issue
Block a user