From c2208f82dc71f612220bc5e80888493cc5335349 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Mon, 9 Jan 2017 13:53:41 -0800 Subject: [PATCH] Convert remaining vars to let/const. --- _baseExtremum.js | 6 ++++-- _baseIntersection.js | 3 ++- _basePullAt.js | 3 ++- _baseSortedIndexBy.js | 3 ++- _createFind.js | 3 ++- _createFlow.js | 7 +++++-- _createWrap.js | 10 ++++++---- _equalArrays.js | 6 ++++-- _getRawTag.js | 3 ++- _hasPath.js | 9 +++++---- _memoizeCapped.js | 2 +- _mergeData.js | 3 ++- 12 files changed, 37 insertions(+), 21 deletions(-) diff --git a/_baseExtremum.js b/_baseExtremum.js index 8929cacbf..5164f19a6 100644 --- a/_baseExtremum.js +++ b/_baseExtremum.js @@ -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; diff --git a/_baseIntersection.js b/_baseIntersection.js index 5ad0cafff..ef55ef34f 100644 --- a/_baseIntersection.js +++ b/_baseIntersection.js @@ -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)); } diff --git a/_basePullAt.js b/_basePullAt.js index ace3465f6..6a262ee82 100644 --- a/_basePullAt.js +++ b/_basePullAt.js @@ -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 { diff --git a/_baseSortedIndexBy.js b/_baseSortedIndexBy.js index bf37a6c4d..c5df85d21 100644 --- a/_baseSortedIndexBy.js +++ b/_baseSortedIndexBy.js @@ -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) { diff --git a/_createFind.js b/_createFind.js index 94a5fbd43..ef0182a67 100644 --- a/_createFind.js +++ b/_createFind.js @@ -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); } diff --git a/_createFlow.js b/_createFlow.js index 180fcb797..131a788c6 100644 --- a/_createFlow.js +++ b/_createFlow.js @@ -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; diff --git a/_createWrap.js b/_createWrap.js index 9049725d1..b45ebdaa9 100644 --- a/_createWrap.js +++ b/_createWrap.js @@ -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) { diff --git a/_equalArrays.js b/_equalArrays.js index 6052699d1..29d1dd8ab 100644 --- a/_equalArrays.js +++ b/_equalArrays.js @@ -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); } diff --git a/_getRawTag.js b/_getRawTag.js index 10d9ace22..0c200f40e 100644 --- a/_getRawTag.js +++ b/_getRawTag.js @@ -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); diff --git a/_hasPath.js b/_hasPath.js index 44c25d3fd..4de656804 100644 --- a/_hasPath.js +++ b/_hasPath.js @@ -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; } diff --git a/_memoizeCapped.js b/_memoizeCapped.js index 7a9eac52e..011716eb0 100644 --- a/_memoizeCapped.js +++ b/_memoizeCapped.js @@ -19,7 +19,7 @@ function memoizeCapped(func) { return key; }); - var cache = result.cache; + const cache = result.cache; return result; } diff --git a/_mergeData.js b/_mergeData.js index 283081fe2..9829fe7fc 100644 --- a/_mergeData.js +++ b/_mergeData.js @@ -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]; }