Convert remaining vars to let/const.

This commit is contained in:
John-David Dalton
2017-01-09 13:53:41 -08:00
parent 40e9c66ca6
commit c2208f82dc
12 changed files with 37 additions and 21 deletions

View File

@@ -11,10 +11,12 @@ import isSymbol from './isSymbol.js';
* @returns {*} Returns the extremum value.
*/
function baseExtremum(array, iteratee, comparator) {
let result;
let index = -1;
const length = array.length;
while (++index < length) {
let computed;
const value = array[index];
const current = iteratee(value);
@@ -22,8 +24,8 @@ function baseExtremum(array, iteratee, comparator) {
? (current === current && !isSymbol(current))
: comparator(current, computed)
)) {
var computed = current,
result = value;
computed = current;
result = value;
}
}
return result;

View File

@@ -25,11 +25,12 @@ function baseIntersection(arrays, iteratee, comparator) {
const caches = Array(othLength);
const result = [];
let array;
let maxLength = Infinity;
let othIndex = othLength;
while (othIndex--) {
var array = arrays[othIndex];
array = arrays[othIndex];
if (othIndex && iteratee) {
array = arrayMap(array, baseUnary(iteratee));
}

View File

@@ -21,9 +21,10 @@ function basePullAt(array, indexes) {
const lastIndex = length - 1;
while (length--) {
let previous;
const index = indexes[length];
if (length == lastIndex || index !== previous) {
var previous = index;
previous = index;
if (isIndex(index)) {
splice.call(array, index, 1);
} else {

View File

@@ -31,6 +31,7 @@ function baseSortedIndexBy(array, value, iteratee, retHighest) {
const valIsUndefined = value === undefined;
while (low < high) {
let setLow;
const mid = nativeFloor((low + high) / 2);
const computed = iteratee(array[mid]);
const othIsDefined = computed !== undefined;
@@ -39,7 +40,7 @@ function baseSortedIndexBy(array, value, iteratee, retHighest) {
const othIsSymbol = isSymbol(computed);
if (valIsNaN) {
var setLow = retHighest || othIsReflexive;
setLow = retHighest || othIsReflexive;
} else if (valIsUndefined) {
setLow = othIsReflexive && (retHighest || othIsDefined);
} else if (valIsNull) {

View File

@@ -11,9 +11,10 @@ import keys from './keys.js';
*/
function createFind(findIndexFunc) {
return (collection, predicate, fromIndex) => {
let iteratee;
const iterable = Object(collection);
if (!isArrayLike(collection)) {
var iteratee = baseIteratee(predicate, 3);
iteratee = baseIteratee(predicate, 3);
collection = keys(collection);
predicate = key => iteratee(iterable[key], key, iterable);
}

View File

@@ -25,18 +25,21 @@ function createFlow(fromRight) {
return flatRest(funcs => {
const length = funcs.length;
const prereq = LodashWrapper.prototype.thru;
let func;
let wrapper;
let index = length;
if (fromRight) {
funcs.reverse();
}
while (index--) {
var func = funcs[index];
func = funcs[index];
if (typeof func != 'function') {
throw new TypeError(FUNC_ERROR_TEXT);
}
if (prereq && !wrapper && getFuncName(func) == 'wrapper') {
var wrapper = new LodashWrapper([], true);
wrapper = new LodashWrapper([], true);
}
}
index = wrapper ? index : length;

View File

@@ -62,10 +62,11 @@ function createWrap(func, bitmask, thisArg, partials, holders, argPos, ary, arit
arity = arity === undefined ? arity : toInteger(arity);
length -= holders ? holders.length : 0;
let holdersRight;
let partialsRight;
if (bitmask & WRAP_PARTIAL_RIGHT_FLAG) {
var partialsRight = partials,
holdersRight = holders;
partialsRight = partials,
holdersRight = holders;
partials = holders = undefined;
}
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)) {
bitmask &= ~(WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG);
}
let result;
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) {
result = createCurry(func, bitmask, arity);
} else if ((bitmask == WRAP_PARTIAL_FLAG || bitmask == (WRAP_BIND_FLAG | WRAP_PARTIAL_FLAG)) && !holders.length) {

View File

@@ -41,10 +41,12 @@ function equalArrays(array, other, bitmask, customizer, equalFunc, stack) {
// Ignore non-index properties.
while (++index < arrLength) {
const arrValue = array[index], othValue = other[index];
let compared;
const arrValue = array[index];
const othValue = other[index];
if (customizer) {
var compared = isPartial
compared = isPartial
? customizer(othValue, arrValue, index, other, array, stack)
: customizer(arrValue, othValue, index, array, other, stack);
}

View File

@@ -26,10 +26,11 @@ const symToStringTag = Symbol ? Symbol.toStringTag : undefined;
function getRawTag(value) {
const isOwn = hasOwnProperty.call(value, symToStringTag);
const tag = value[symToStringTag];
let unmasked = false;
try {
value[symToStringTag] = undefined;
var unmasked = true;
unmasked = true;
} catch (e) {}
const result = nativeObjectToString.call(value);

View File

@@ -17,12 +17,13 @@ import toKey from './_toKey.js';
function hasPath(object, path, hasFunc) {
path = castPath(path, object);
let index = -1,
length = path.length,
result = false;
let key;
let index = -1;
let length = path.length;
let result = false;
while (++index < length) {
var key = toKey(path[index]);
key = toKey(path[index]);
if (!(result = object != null && hasFunc(object, key))) {
break;
}

View File

@@ -19,7 +19,7 @@ function memoizeCapped(func) {
return key;
});
var cache = result.cache;
const cache = result.cache;
return result;
}

View File

@@ -55,9 +55,10 @@ function mergeData(data, source) {
newBitmask |= bitmask & WRAP_BIND_FLAG ? 0 : WRAP_CURRY_BOUND_FLAG;
}
// Compose partial arguments.
let partials;
let value = source[3];
if (value) {
var partials = data[3];
partials = data[3];
data[3] = partials ? composeArgs(partials, value, source[4]) : value;
data[4] = partials ? replaceHolders(data[3], PLACEHOLDER) : source[4];
}