mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-13 12:27:49 +00:00
Adjust getCallback use in _.max, _.min, _.sortedIndex, & _.sortedLastIndex.
This commit is contained in:
39
lodash.js
39
lodash.js
@@ -4811,8 +4811,11 @@
|
|||||||
* // => 1
|
* // => 1
|
||||||
*/
|
*/
|
||||||
function sortedIndex(array, value, iteratee, thisArg) {
|
function sortedIndex(array, value, iteratee, thisArg) {
|
||||||
iteratee = getCallback(iteratee, thisArg, 1);
|
var func = getCallback(iteratee);
|
||||||
return binaryIndex(array, value, iteratee === identity ? null : iteratee);
|
if (!(func === baseCallback && iteratee == null)) {
|
||||||
|
iteratee = func(iteratee, thisArg, 1);
|
||||||
|
}
|
||||||
|
return binaryIndex(array, value, iteratee);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -4837,8 +4840,11 @@
|
|||||||
* // => 4
|
* // => 4
|
||||||
*/
|
*/
|
||||||
function sortedLastIndex(array, value, iteratee, thisArg) {
|
function sortedLastIndex(array, value, iteratee, thisArg) {
|
||||||
iteratee = getCallback(iteratee, thisArg, 1);
|
var func = getCallback();
|
||||||
return binaryIndex(array, value, iteratee === identity ? null : iteratee, true);
|
if (!(func === baseCallback && iteratee == null)) {
|
||||||
|
iteratee = func(iteratee, thisArg, 1);
|
||||||
|
}
|
||||||
|
return binaryIndex(array, value, iteratee, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -5085,9 +5091,9 @@
|
|||||||
iteratee = isIterateeCall(array, isSorted, thisArg) ? null : isSorted;
|
iteratee = isIterateeCall(array, isSorted, thisArg) ? null : isSorted;
|
||||||
isSorted = false;
|
isSorted = false;
|
||||||
}
|
}
|
||||||
iteratee = getCallback(iteratee, thisArg, 3);
|
var func = getCallback();
|
||||||
if (iteratee === identity) {
|
if (!(func === baseCallback && iteratee == null)) {
|
||||||
iteratee = null;
|
iteratee = func(iteratee, thisArg, 3);
|
||||||
}
|
}
|
||||||
return (isSorted && getIndexOf() == baseIndexOf)
|
return (isSorted && getIndexOf() == baseIndexOf)
|
||||||
? sortedUniq(array, iteratee)
|
? sortedUniq(array, iteratee)
|
||||||
@@ -5989,12 +5995,15 @@
|
|||||||
if (thisArg && isIterateeCall(collection, iteratee, thisArg)) {
|
if (thisArg && isIterateeCall(collection, iteratee, thisArg)) {
|
||||||
iteratee = null;
|
iteratee = null;
|
||||||
}
|
}
|
||||||
iteratee = getCallback(iteratee, thisArg, 3);
|
var noIteratee = iteratee == null,
|
||||||
|
func = getCallback(),
|
||||||
var noIteratee = iteratee === identity,
|
|
||||||
isArr = noIteratee && isArray(collection),
|
isArr = noIteratee && isArray(collection),
|
||||||
isStr = !isArr && isString(collection);
|
isStr = !isArr && isString(collection);
|
||||||
|
|
||||||
|
if (!(func === baseCallback && noIteratee)) {
|
||||||
|
noIteratee = false;
|
||||||
|
iteratee = func(iteratee, thisArg, 3);
|
||||||
|
}
|
||||||
if (noIteratee) {
|
if (noIteratee) {
|
||||||
if (isStr) {
|
if (isStr) {
|
||||||
iteratee = charAtCallback;
|
iteratee = charAtCallback;
|
||||||
@@ -6062,12 +6071,16 @@
|
|||||||
if (thisArg && isIterateeCall(collection, iteratee, thisArg)) {
|
if (thisArg && isIterateeCall(collection, iteratee, thisArg)) {
|
||||||
iteratee = null;
|
iteratee = null;
|
||||||
}
|
}
|
||||||
iteratee = getCallback(iteratee, thisArg, 3);
|
var noIteratee = iteratee == null,
|
||||||
|
func = getCallback(),
|
||||||
var noIteratee = iteratee === identity,
|
|
||||||
isArr = noIteratee && isArray(collection),
|
isArr = noIteratee && isArray(collection),
|
||||||
isStr = !isArr && isString(collection);
|
isStr = !isArr && isString(collection);
|
||||||
|
|
||||||
|
|
||||||
|
if (!(func === baseCallback && noIteratee)) {
|
||||||
|
noIteratee = false;
|
||||||
|
iteratee = func(iteratee, thisArg, 3);
|
||||||
|
}
|
||||||
if (noIteratee) {
|
if (noIteratee) {
|
||||||
if (isStr) {
|
if (isStr) {
|
||||||
iteratee = charAtCallback;
|
iteratee = charAtCallback;
|
||||||
|
|||||||
Reference in New Issue
Block a user