mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-12 03:47:50 +00:00
Convert remaining vars to let/const.
This commit is contained in:
@@ -11,10 +11,12 @@ import isSymbol from './isSymbol.js';
|
|||||||
* @returns {*} Returns the extremum value.
|
* @returns {*} Returns the extremum value.
|
||||||
*/
|
*/
|
||||||
function baseExtremum(array, iteratee, comparator) {
|
function baseExtremum(array, iteratee, comparator) {
|
||||||
|
let result;
|
||||||
let index = -1;
|
let index = -1;
|
||||||
const length = array.length;
|
const length = array.length;
|
||||||
|
|
||||||
while (++index < length) {
|
while (++index < length) {
|
||||||
|
let computed;
|
||||||
const value = array[index];
|
const value = array[index];
|
||||||
const current = iteratee(value);
|
const current = iteratee(value);
|
||||||
|
|
||||||
@@ -22,8 +24,8 @@ function baseExtremum(array, iteratee, comparator) {
|
|||||||
? (current === current && !isSymbol(current))
|
? (current === current && !isSymbol(current))
|
||||||
: comparator(current, computed)
|
: comparator(current, computed)
|
||||||
)) {
|
)) {
|
||||||
var computed = current,
|
computed = current;
|
||||||
result = value;
|
result = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
|||||||
@@ -25,11 +25,12 @@ function baseIntersection(arrays, iteratee, comparator) {
|
|||||||
const caches = Array(othLength);
|
const caches = Array(othLength);
|
||||||
const result = [];
|
const result = [];
|
||||||
|
|
||||||
|
let array;
|
||||||
let maxLength = Infinity;
|
let maxLength = Infinity;
|
||||||
let othIndex = othLength;
|
let othIndex = othLength;
|
||||||
|
|
||||||
while (othIndex--) {
|
while (othIndex--) {
|
||||||
var array = arrays[othIndex];
|
array = arrays[othIndex];
|
||||||
if (othIndex && iteratee) {
|
if (othIndex && iteratee) {
|
||||||
array = arrayMap(array, baseUnary(iteratee));
|
array = arrayMap(array, baseUnary(iteratee));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,9 +21,10 @@ function basePullAt(array, indexes) {
|
|||||||
const lastIndex = length - 1;
|
const lastIndex = length - 1;
|
||||||
|
|
||||||
while (length--) {
|
while (length--) {
|
||||||
|
let previous;
|
||||||
const index = indexes[length];
|
const index = indexes[length];
|
||||||
if (length == lastIndex || index !== previous) {
|
if (length == lastIndex || index !== previous) {
|
||||||
var previous = index;
|
previous = index;
|
||||||
if (isIndex(index)) {
|
if (isIndex(index)) {
|
||||||
splice.call(array, index, 1);
|
splice.call(array, index, 1);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ function baseSortedIndexBy(array, value, iteratee, retHighest) {
|
|||||||
const valIsUndefined = value === undefined;
|
const valIsUndefined = value === undefined;
|
||||||
|
|
||||||
while (low < high) {
|
while (low < high) {
|
||||||
|
let setLow;
|
||||||
const mid = nativeFloor((low + high) / 2);
|
const mid = nativeFloor((low + high) / 2);
|
||||||
const computed = iteratee(array[mid]);
|
const computed = iteratee(array[mid]);
|
||||||
const othIsDefined = computed !== undefined;
|
const othIsDefined = computed !== undefined;
|
||||||
@@ -39,7 +40,7 @@ function baseSortedIndexBy(array, value, iteratee, retHighest) {
|
|||||||
const othIsSymbol = isSymbol(computed);
|
const othIsSymbol = isSymbol(computed);
|
||||||
|
|
||||||
if (valIsNaN) {
|
if (valIsNaN) {
|
||||||
var setLow = retHighest || othIsReflexive;
|
setLow = retHighest || othIsReflexive;
|
||||||
} else if (valIsUndefined) {
|
} else if (valIsUndefined) {
|
||||||
setLow = othIsReflexive && (retHighest || othIsDefined);
|
setLow = othIsReflexive && (retHighest || othIsDefined);
|
||||||
} else if (valIsNull) {
|
} else if (valIsNull) {
|
||||||
|
|||||||
@@ -11,9 +11,10 @@ import keys from './keys.js';
|
|||||||
*/
|
*/
|
||||||
function createFind(findIndexFunc) {
|
function createFind(findIndexFunc) {
|
||||||
return (collection, predicate, fromIndex) => {
|
return (collection, predicate, fromIndex) => {
|
||||||
|
let iteratee;
|
||||||
const iterable = Object(collection);
|
const iterable = Object(collection);
|
||||||
if (!isArrayLike(collection)) {
|
if (!isArrayLike(collection)) {
|
||||||
var iteratee = baseIteratee(predicate, 3);
|
iteratee = baseIteratee(predicate, 3);
|
||||||
collection = keys(collection);
|
collection = keys(collection);
|
||||||
predicate = key => iteratee(iterable[key], key, iterable);
|
predicate = key => iteratee(iterable[key], key, iterable);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,18 +25,21 @@ function createFlow(fromRight) {
|
|||||||
return flatRest(funcs => {
|
return flatRest(funcs => {
|
||||||
const length = funcs.length;
|
const length = funcs.length;
|
||||||
const prereq = LodashWrapper.prototype.thru;
|
const prereq = LodashWrapper.prototype.thru;
|
||||||
|
|
||||||
|
let func;
|
||||||
|
let wrapper;
|
||||||
let index = length;
|
let index = length;
|
||||||
|
|
||||||
if (fromRight) {
|
if (fromRight) {
|
||||||
funcs.reverse();
|
funcs.reverse();
|
||||||
}
|
}
|
||||||
while (index--) {
|
while (index--) {
|
||||||
var func = funcs[index];
|
func = funcs[index];
|
||||||
if (typeof func != 'function') {
|
if (typeof func != 'function') {
|
||||||
throw new TypeError(FUNC_ERROR_TEXT);
|
throw new TypeError(FUNC_ERROR_TEXT);
|
||||||
}
|
}
|
||||||
if (prereq && !wrapper && getFuncName(func) == 'wrapper') {
|
if (prereq && !wrapper && getFuncName(func) == 'wrapper') {
|
||||||
var wrapper = new LodashWrapper([], true);
|
wrapper = new LodashWrapper([], true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
index = wrapper ? index : length;
|
index = wrapper ? index : length;
|
||||||
|
|||||||
@@ -62,10 +62,11 @@ function createWrap(func, bitmask, thisArg, partials, holders, argPos, ary, arit
|
|||||||
arity = arity === undefined ? arity : toInteger(arity);
|
arity = arity === undefined ? arity : toInteger(arity);
|
||||||
length -= holders ? holders.length : 0;
|
length -= holders ? holders.length : 0;
|
||||||
|
|
||||||
|
let holdersRight;
|
||||||
|
let partialsRight;
|
||||||
if (bitmask & WRAP_PARTIAL_RIGHT_FLAG) {
|
if (bitmask & WRAP_PARTIAL_RIGHT_FLAG) {
|
||||||
var partialsRight = partials,
|
partialsRight = partials,
|
||||||
holdersRight = holders;
|
holdersRight = holders;
|
||||||
|
|
||||||
partials = holders = undefined;
|
partials = holders = undefined;
|
||||||
}
|
}
|
||||||
const data = isBindKey ? undefined : getData(func);
|
const data = isBindKey ? undefined : getData(func);
|
||||||
@@ -90,8 +91,9 @@ function createWrap(func, bitmask, thisArg, partials, holders, argPos, ary, arit
|
|||||||
if (!arity && bitmask & (WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG)) {
|
if (!arity && bitmask & (WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG)) {
|
||||||
bitmask &= ~(WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG);
|
bitmask &= ~(WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG);
|
||||||
}
|
}
|
||||||
|
let result;
|
||||||
if (!bitmask || bitmask == WRAP_BIND_FLAG) {
|
if (!bitmask || bitmask == WRAP_BIND_FLAG) {
|
||||||
var result = createBind(func, bitmask, thisArg);
|
result = createBind(func, bitmask, thisArg);
|
||||||
} else if (bitmask == WRAP_CURRY_FLAG || bitmask == WRAP_CURRY_RIGHT_FLAG) {
|
} else if (bitmask == WRAP_CURRY_FLAG || bitmask == WRAP_CURRY_RIGHT_FLAG) {
|
||||||
result = createCurry(func, bitmask, arity);
|
result = createCurry(func, bitmask, arity);
|
||||||
} else if ((bitmask == WRAP_PARTIAL_FLAG || bitmask == (WRAP_BIND_FLAG | WRAP_PARTIAL_FLAG)) && !holders.length) {
|
} else if ((bitmask == WRAP_PARTIAL_FLAG || bitmask == (WRAP_BIND_FLAG | WRAP_PARTIAL_FLAG)) && !holders.length) {
|
||||||
|
|||||||
@@ -41,10 +41,12 @@ function equalArrays(array, other, bitmask, customizer, equalFunc, stack) {
|
|||||||
|
|
||||||
// Ignore non-index properties.
|
// Ignore non-index properties.
|
||||||
while (++index < arrLength) {
|
while (++index < arrLength) {
|
||||||
const arrValue = array[index], othValue = other[index];
|
let compared;
|
||||||
|
const arrValue = array[index];
|
||||||
|
const othValue = other[index];
|
||||||
|
|
||||||
if (customizer) {
|
if (customizer) {
|
||||||
var compared = isPartial
|
compared = isPartial
|
||||||
? customizer(othValue, arrValue, index, other, array, stack)
|
? customizer(othValue, arrValue, index, other, array, stack)
|
||||||
: customizer(arrValue, othValue, index, array, other, stack);
|
: customizer(arrValue, othValue, index, array, other, stack);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,10 +26,11 @@ const symToStringTag = Symbol ? Symbol.toStringTag : undefined;
|
|||||||
function getRawTag(value) {
|
function getRawTag(value) {
|
||||||
const isOwn = hasOwnProperty.call(value, symToStringTag);
|
const isOwn = hasOwnProperty.call(value, symToStringTag);
|
||||||
const tag = value[symToStringTag];
|
const tag = value[symToStringTag];
|
||||||
|
let unmasked = false;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
value[symToStringTag] = undefined;
|
value[symToStringTag] = undefined;
|
||||||
var unmasked = true;
|
unmasked = true;
|
||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
|
|
||||||
const result = nativeObjectToString.call(value);
|
const result = nativeObjectToString.call(value);
|
||||||
|
|||||||
@@ -17,12 +17,13 @@ import toKey from './_toKey.js';
|
|||||||
function hasPath(object, path, hasFunc) {
|
function hasPath(object, path, hasFunc) {
|
||||||
path = castPath(path, object);
|
path = castPath(path, object);
|
||||||
|
|
||||||
let index = -1,
|
let key;
|
||||||
length = path.length,
|
let index = -1;
|
||||||
result = false;
|
let length = path.length;
|
||||||
|
let result = false;
|
||||||
|
|
||||||
while (++index < length) {
|
while (++index < length) {
|
||||||
var key = toKey(path[index]);
|
key = toKey(path[index]);
|
||||||
if (!(result = object != null && hasFunc(object, key))) {
|
if (!(result = object != null && hasFunc(object, key))) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ function memoizeCapped(func) {
|
|||||||
return key;
|
return key;
|
||||||
});
|
});
|
||||||
|
|
||||||
var cache = result.cache;
|
const cache = result.cache;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -55,9 +55,10 @@ function mergeData(data, source) {
|
|||||||
newBitmask |= bitmask & WRAP_BIND_FLAG ? 0 : WRAP_CURRY_BOUND_FLAG;
|
newBitmask |= bitmask & WRAP_BIND_FLAG ? 0 : WRAP_CURRY_BOUND_FLAG;
|
||||||
}
|
}
|
||||||
// Compose partial arguments.
|
// Compose partial arguments.
|
||||||
|
let partials;
|
||||||
let value = source[3];
|
let value = source[3];
|
||||||
if (value) {
|
if (value) {
|
||||||
var partials = data[3];
|
partials = data[3];
|
||||||
data[3] = partials ? composeArgs(partials, value, source[4]) : value;
|
data[3] = partials ? composeArgs(partials, value, source[4]) : value;
|
||||||
data[4] = partials ? replaceHolders(data[3], PLACEHOLDER) : source[4];
|
data[4] = partials ? replaceHolders(data[3], PLACEHOLDER) : source[4];
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user