mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-08 02:17:48 +00:00
Ignore isSorted if _.indexOf is customized.
This commit is contained in:
@@ -2397,11 +2397,12 @@
|
|||||||
}
|
}
|
||||||
var index = -1,
|
var index = -1,
|
||||||
indexOf = getIndexOf(),
|
indexOf = getIndexOf(),
|
||||||
prereq = !isSorted && indexOf === baseIndexOf,
|
prereq = indexOf === baseIndexOf,
|
||||||
isLarge = prereq && createCache && length >= 200,
|
isLarge = prereq && createCache && length >= 200,
|
||||||
isCommon = prereq && !isLarge,
|
isCommon = prereq && !isLarge,
|
||||||
result = [];
|
result = [];
|
||||||
|
|
||||||
|
isSorted = prereq && isSorted;
|
||||||
if (isLarge) {
|
if (isLarge) {
|
||||||
var seen = createCache();
|
var seen = createCache();
|
||||||
indexOf = cacheIndexOf;
|
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) {
|
if (!isModularize) {
|
||||||
_.indexOf = custom;
|
_.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;
|
_.indexOf = indexOf;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|||||||
Reference in New Issue
Block a user