From dc687c1d854e20504d073671f9f4b5452791ab50 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Mon, 9 Jan 2017 12:23:34 -0800 Subject: [PATCH] Apply even more let/const transforms. --- _Set.js | 2 +- _SetCache.js | 4 ++-- _Stack.js | 2 +- _Symbol.js | 2 +- _Uint8Array.js | 2 +- _WeakMap.js | 2 +- _hasUnicode.js | 16 ++++++++-------- _initCloneByTag.js | 40 ++++++++++++++++++++-------------------- _insertWrapDetails.js | 2 +- _listCacheDelete.js | 10 +++++----- _listCacheGet.js | 4 ++-- _listCacheSet.js | 4 ++-- _mapToArray.js | 4 ++-- _memoizeCapped.js | 4 ++-- _mergeData.js | 29 +++++++++++++++-------------- _metaMap.js | 2 +- _nativeCreate.js | 2 +- _nativeKeys.js | 2 +- _nativeKeysIn.js | 4 ++-- _nodeUtil.js | 10 +++++----- _objectToString.js | 4 ++-- _overRest.js | 12 ++++++------ _reorder.js | 10 +++++----- _replaceHolders.js | 12 ++++++------ _root.js | 4 ++-- _setCacheAdd.js | 2 +- _shortOut.js | 14 +++++++------- _stackDelete.js | 4 ++-- _stackSet.js | 6 +++--- _strictIndexOf.js | 4 ++-- _strictLastIndexOf.js | 2 +- _stringToPath.js | 9 ++++----- _toKey.js | 2 +- _toSource.js | 4 ++-- _unescapeHtmlChar.js | 4 ++-- _updateWrapDetails.js | 22 +++++++++++----------- _wrapperClone.js | 2 +- add.js | 2 +- after.js | 2 +- ary.js | 2 +- assignIn.js | 2 +- assignInWith.js | 2 +- assignWith.js | 2 +- at.js | 2 +- attempt.js | 2 +- before.js | 4 ++-- bind.js | 11 ++++++----- bindAll.js | 2 +- bindKey.js | 13 +++++++------ camelCase.js | 2 +- castArray.js | 2 +- ceil.js | 2 +- chunk.js | 12 ++++++------ clone.js | 2 +- cloneDeep.js | 4 ++-- cloneDeepWith.js | 4 ++-- cloneWith.js | 2 +- compact.js | 10 +++++----- concat.js | 8 ++++---- cond.js | 10 +++++----- conforms.js | 2 +- countBy.js | 6 +++--- create.js | 2 +- curry.js | 4 ++-- curryRight.js | 4 ++-- debounce.js | 39 ++++++++++++++++++++------------------- defaults.js | 2 +- defaultsDeep.js | 2 +- defer.js | 5 +++-- delay.js | 5 +++-- difference.js | 9 +++++---- differenceBy.js | 7 +++---- differenceWith.js | 7 +++---- divide.js | 2 +- drop.js | 2 +- dropRight.js | 2 +- endsWith.js | 4 ++-- escape.js | 4 ++-- escapeRegExp.js | 4 ++-- every.js | 2 +- fill.js | 2 +- filter.js | 2 +- find.js | 2 +- findIndex.js | 6 +++--- findLast.js | 2 +- findLastIndex.js | 8 ++++---- flatMapDeep.js | 2 +- flatten.js | 2 +- flattenDeep.js | 4 ++-- flattenDepth.js | 2 +- flip.js | 2 +- floor.js | 2 +- flow.js | 2 +- flowRight.js | 2 +- forEach.js | 2 +- forEachRight.js | 2 +- fromPairs.js | 8 ++++---- get.js | 2 +- groupBy.js | 6 +++--- gt.js | 2 +- gte.js | 2 +- includes.js | 4 ++-- indexOf.js | 6 +++--- initial.js | 2 +- intersection.js | 7 +++---- intersectionBy.js | 9 ++++----- intersectionWith.js | 9 ++++----- invert.js | 2 +- invertBy.js | 6 +++--- invoke.js | 2 +- invokeMap.js | 11 +++++------ isArguments.js | 8 ++++---- isArrayBuffer.js | 4 ++-- isBoolean.js | 2 +- isBuffer.js | 12 ++++++------ isDate.js | 4 ++-- isEmpty.js | 12 ++++++------ isEqualWith.js | 2 +- isError.js | 6 +++--- isFinite.js | 2 +- isFunction.js | 10 +++++----- isLength.js | 2 +- isMap.js | 4 ++-- isNative.js | 2 +- isNumber.js | 2 +- isObject.js | 2 +- isPlainObject.js | 16 ++++++++-------- isRegExp.js | 4 ++-- isSafeInteger.js | 2 +- isSet.js | 4 ++-- isString.js | 2 +- isSymbol.js | 2 +- isTypedArray.js | 4 ++-- isWeakMap.js | 2 +- isWeakSet.js | 2 +- join.js | 4 ++-- kebabCase.js | 2 +- keyBy.js | 2 +- last.js | 2 +- lastIndexOf.js | 8 ++++---- lowerCase.js | 2 +- lowerFirst.js | 2 +- lt.js | 2 +- lte.js | 2 +- map.js | 2 +- mapKeys.js | 2 +- mapValues.js | 2 +- matches.js | 2 +- matchesProperty.js | 2 +- memoize.js | 11 +++++------ merge.js | 2 +- mergeWith.js | 2 +- method.js | 2 +- methodOf.js | 2 +- multiply.js | 2 +- negate.js | 4 ++-- now.js | 2 +- over.js | 2 +- overArgs.js | 18 ++++++++---------- overEvery.js | 2 +- overSome.js | 2 +- pad.js | 8 ++++---- padEnd.js | 2 +- padStart.js | 2 +- parseInt.js | 4 ++-- pick.js | 2 +- pickBy.js | 2 +- pull.js | 2 +- pullAt.js | 5 ++--- random.js | 10 +++++----- range.js | 2 +- rangeRight.js | 2 +- rearg.js | 4 ++-- reduce.js | 4 ++-- reduceRight.js | 4 ++-- remove.js | 10 +++++----- replace.js | 4 ++-- 177 files changed, 433 insertions(+), 437 deletions(-) diff --git a/_Set.js b/_Set.js index 2f952099a..76a463b38 100644 --- a/_Set.js +++ b/_Set.js @@ -2,6 +2,6 @@ import getNative from './_getNative.js'; import root from './_root.js'; /* Built-in method references that are verified to be native. */ -var Set = getNative(root, 'Set'); +const Set = getNative(root, 'Set'); export default Set; diff --git a/_SetCache.js b/_SetCache.js index 12455ff42..4f01e1168 100644 --- a/_SetCache.js +++ b/_SetCache.js @@ -11,8 +11,8 @@ import setCacheHas from './_setCacheHas.js'; * @param {Array} [values] The values to cache. */ function SetCache(values) { - var index = -1, - length = values == null ? 0 : values.length; + let index = -1; + const length = values == null ? 0 : values.length; this.__data__ = new MapCache; while (++index < length) { diff --git a/_Stack.js b/_Stack.js index 77c3cf311..abc656c14 100644 --- a/_Stack.js +++ b/_Stack.js @@ -13,7 +13,7 @@ import stackSet from './_stackSet.js'; * @param {Array} [entries] The key-value pairs to cache. */ function Stack(entries) { - var data = this.__data__ = new ListCache(entries); + const data = this.__data__ = new ListCache(entries); this.size = data.size; } diff --git a/_Symbol.js b/_Symbol.js index 2b9341c33..8ef83f446 100644 --- a/_Symbol.js +++ b/_Symbol.js @@ -1,6 +1,6 @@ import root from './_root.js'; /** Built-in value references. */ -var Symbol = root.Symbol; +const Symbol = root.Symbol; export default Symbol; diff --git a/_Uint8Array.js b/_Uint8Array.js index f463674d2..d79ae15b5 100644 --- a/_Uint8Array.js +++ b/_Uint8Array.js @@ -1,6 +1,6 @@ import root from './_root.js'; /** Built-in value references. */ -var Uint8Array = root.Uint8Array; +const Uint8Array = root.Uint8Array; export default Uint8Array; diff --git a/_WeakMap.js b/_WeakMap.js index 6f97de58c..c305a9c99 100644 --- a/_WeakMap.js +++ b/_WeakMap.js @@ -2,6 +2,6 @@ import getNative from './_getNative.js'; import root from './_root.js'; /* Built-in method references that are verified to be native. */ -var WeakMap = getNative(root, 'WeakMap'); +const WeakMap = getNative(root, 'WeakMap'); export default WeakMap; diff --git a/_hasUnicode.js b/_hasUnicode.js index 359a7e7fe..d13b73ec0 100644 --- a/_hasUnicode.js +++ b/_hasUnicode.js @@ -1,16 +1,16 @@ /** Used to compose unicode character classes. */ -var rsAstralRange = '\\ud800-\\udfff', - rsComboMarksRange = '\\u0300-\\u036f', - reComboHalfMarksRange = '\\ufe20-\\ufe2f', - rsComboSymbolsRange = '\\u20d0-\\u20ff', - rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange, - rsVarRange = '\\ufe0e\\ufe0f'; +const rsAstralRange = '\\ud800-\\udfff'; +const rsComboMarksRange = '\\u0300-\\u036f'; +const reComboHalfMarksRange = '\\ufe20-\\ufe2f'; +const rsComboSymbolsRange = '\\u20d0-\\u20ff'; +const rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange; +const rsVarRange = '\\ufe0e\\ufe0f'; /** Used to compose unicode capture groups. */ -var rsZWJ = '\\u200d'; +const rsZWJ = '\\u200d'; /** Used to detect strings with [zero-width joiners or code points from the astral planes](http://eev.ee/blog/2015/09/12/dark-corners-of-unicode/). */ -var reHasUnicode = RegExp(`[${ rsZWJ + rsAstralRange + rsComboRange + rsVarRange }]`); +const reHasUnicode = RegExp(`[${ rsZWJ + rsAstralRange + rsComboRange + rsVarRange }]`); /** * Checks if `string` contains Unicode symbols. diff --git a/_initCloneByTag.js b/_initCloneByTag.js index f7f3eac58..3a7e8d3c2 100644 --- a/_initCloneByTag.js +++ b/_initCloneByTag.js @@ -7,26 +7,26 @@ import cloneSymbol from './_cloneSymbol.js'; import cloneTypedArray from './_cloneTypedArray.js'; /** `Object#toString` result references. */ -var boolTag = '[object Boolean]', - dateTag = '[object Date]', - mapTag = '[object Map]', - numberTag = '[object Number]', - regexpTag = '[object RegExp]', - setTag = '[object Set]', - stringTag = '[object String]', - symbolTag = '[object Symbol]'; +const boolTag = '[object Boolean]'; +const dateTag = '[object Date]'; +const mapTag = '[object Map]'; +const numberTag = '[object Number]'; +const regexpTag = '[object RegExp]'; +const setTag = '[object Set]'; +const stringTag = '[object String]'; +const symbolTag = '[object Symbol]'; -var arrayBufferTag = '[object ArrayBuffer]', - dataViewTag = '[object DataView]', - float32Tag = '[object Float32Array]', - float64Tag = '[object Float64Array]', - int8Tag = '[object Int8Array]', - int16Tag = '[object Int16Array]', - int32Tag = '[object Int32Array]', - uint8Tag = '[object Uint8Array]', - uint8ClampedTag = '[object Uint8ClampedArray]', - uint16Tag = '[object Uint16Array]', - uint32Tag = '[object Uint32Array]'; +const arrayBufferTag = '[object ArrayBuffer]'; +const dataViewTag = '[object DataView]'; +const float32Tag = '[object Float32Array]'; +const float64Tag = '[object Float64Array]'; +const int8Tag = '[object Int8Array]'; +const int16Tag = '[object Int16Array]'; +const int32Tag = '[object Int32Array]'; +const uint8Tag = '[object Uint8Array]'; +const uint8ClampedTag = '[object Uint8ClampedArray]'; +const uint16Tag = '[object Uint16Array]'; +const uint32Tag = '[object Uint32Array]'; /** * Initializes an object clone based on its `toStringTag`. @@ -42,7 +42,7 @@ var arrayBufferTag = '[object ArrayBuffer]', * @returns {Object} Returns the initialized clone. */ function initCloneByTag(object, tag, cloneFunc, isDeep) { - var Ctor = object.constructor; + const Ctor = object.constructor; switch (tag) { case arrayBufferTag: return cloneArrayBuffer(object); diff --git a/_insertWrapDetails.js b/_insertWrapDetails.js index 39c9e8cf8..7e1879a8c 100644 --- a/_insertWrapDetails.js +++ b/_insertWrapDetails.js @@ -1,5 +1,5 @@ /** Used to match wrap detail comments. */ -var reWrapComment = /\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/; +const reWrapComment = /\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/; /** * Inserts wrapper `details` in a comment at the top of the `source` body. diff --git a/_listCacheDelete.js b/_listCacheDelete.js index b08c834a7..00162bd92 100644 --- a/_listCacheDelete.js +++ b/_listCacheDelete.js @@ -1,10 +1,10 @@ import assocIndexOf from './_assocIndexOf.js'; /** Used for built-in method references. */ -var arrayProto = Array.prototype; +const arrayProto = Array.prototype; /** Built-in value references. */ -var splice = arrayProto.splice; +const splice = arrayProto.splice; /** * Removes `key` and its value from the list cache. @@ -16,13 +16,13 @@ var splice = arrayProto.splice; * @returns {boolean} Returns `true` if the entry was removed, else `false`. */ function listCacheDelete(key) { - var data = this.__data__, - index = assocIndexOf(data, key); + const data = this.__data__; + const index = assocIndexOf(data, key); if (index < 0) { return false; } - var lastIndex = data.length - 1; + const lastIndex = data.length - 1; if (index == lastIndex) { data.pop(); } else { diff --git a/_listCacheGet.js b/_listCacheGet.js index 53ce0017d..0e217817f 100644 --- a/_listCacheGet.js +++ b/_listCacheGet.js @@ -10,8 +10,8 @@ import assocIndexOf from './_assocIndexOf.js'; * @returns {*} Returns the entry value. */ function listCacheGet(key) { - var data = this.__data__, - index = assocIndexOf(data, key); + const data = this.__data__; + const index = assocIndexOf(data, key); return index < 0 ? undefined : data[index][1]; } diff --git a/_listCacheSet.js b/_listCacheSet.js index 8c5a1980e..b9da6e58b 100644 --- a/_listCacheSet.js +++ b/_listCacheSet.js @@ -11,8 +11,8 @@ import assocIndexOf from './_assocIndexOf.js'; * @returns {Object} Returns the list cache instance. */ function listCacheSet(key, value) { - var data = this.__data__, - index = assocIndexOf(data, key); + const data = this.__data__; + const index = assocIndexOf(data, key); if (index < 0) { ++this.size; diff --git a/_mapToArray.js b/_mapToArray.js index ce1729dfb..307131217 100644 --- a/_mapToArray.js +++ b/_mapToArray.js @@ -6,8 +6,8 @@ * @returns {Array} Returns the key-value pairs. */ function mapToArray(map) { - var index = -1, - result = Array(map.size); + let index = -1; + const result = Array(map.size); map.forEach((value, key) => { result[++index] = [key, value]; diff --git a/_memoizeCapped.js b/_memoizeCapped.js index 007be5679..7a9eac52e 100644 --- a/_memoizeCapped.js +++ b/_memoizeCapped.js @@ -1,7 +1,7 @@ import memoize from './memoize.js'; /** Used as the maximum memoize cache size. */ -var MAX_MEMOIZE_SIZE = 500; +const MAX_MEMOIZE_SIZE = 500; /** * A specialized version of `_.memoize` which clears the memoized function's @@ -12,7 +12,7 @@ var MAX_MEMOIZE_SIZE = 500; * @returns {Function} Returns the new memoized function. */ function memoizeCapped(func) { - var result = memoize(func, key => { + const result = memoize(func, key => { if (cache.size === MAX_MEMOIZE_SIZE) { cache.clear(); } diff --git a/_mergeData.js b/_mergeData.js index 9222069f8..283081fe2 100644 --- a/_mergeData.js +++ b/_mergeData.js @@ -3,18 +3,18 @@ import composeArgsRight from './_composeArgsRight.js'; import replaceHolders from './_replaceHolders.js'; /** Used as the internal argument placeholder. */ -var PLACEHOLDER = '__lodash_placeholder__'; +const PLACEHOLDER = '__lodash_placeholder__'; /** Used to compose bitmasks for function metadata. */ -var WRAP_BIND_FLAG = 1, - WRAP_BIND_KEY_FLAG = 2, - WRAP_CURRY_BOUND_FLAG = 4, - WRAP_CURRY_FLAG = 8, - WRAP_ARY_FLAG = 128, - WRAP_REARG_FLAG = 256; +const WRAP_BIND_FLAG = 1; +const WRAP_BIND_KEY_FLAG = 2; +const WRAP_CURRY_BOUND_FLAG = 4; +const WRAP_CURRY_FLAG = 8; +const WRAP_ARY_FLAG = 128; +const WRAP_REARG_FLAG = 256; /* Built-in method references for those with the same name as other `lodash` methods. */ -var nativeMin = Math.min; +const nativeMin = Math.min; /** * Merges the function metadata of `source` into `data`. @@ -33,12 +33,13 @@ var nativeMin = Math.min; * @returns {Array} Returns `data`. */ function mergeData(data, source) { - var bitmask = data[1], - srcBitmask = source[1], - newBitmask = bitmask | srcBitmask, - isCommon = newBitmask < (WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG | WRAP_ARY_FLAG); + const bitmask = data[1]; + const srcBitmask = source[1]; - var isCombo = + let newBitmask = bitmask | srcBitmask; + const isCommon = newBitmask < (WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG | WRAP_ARY_FLAG); + + const isCombo = ((srcBitmask == WRAP_ARY_FLAG) && (bitmask == WRAP_CURRY_FLAG)) || ((srcBitmask == WRAP_ARY_FLAG) && (bitmask == WRAP_REARG_FLAG) && (data[7].length <= source[8])) || ((srcBitmask == (WRAP_ARY_FLAG | WRAP_REARG_FLAG)) && (source[7].length <= source[8]) && (bitmask == WRAP_CURRY_FLAG)); @@ -54,7 +55,7 @@ function mergeData(data, source) { newBitmask |= bitmask & WRAP_BIND_FLAG ? 0 : WRAP_CURRY_BOUND_FLAG; } // Compose partial arguments. - var value = source[3]; + let value = source[3]; if (value) { var partials = data[3]; data[3] = partials ? composeArgs(partials, value, source[4]) : value; diff --git a/_metaMap.js b/_metaMap.js index d7e5b9518..440d454ca 100644 --- a/_metaMap.js +++ b/_metaMap.js @@ -1,6 +1,6 @@ import WeakMap from './_WeakMap.js'; /** Used to store function metadata. */ -var metaMap = WeakMap && new WeakMap; +const metaMap = WeakMap && new WeakMap; export default metaMap; diff --git a/_nativeCreate.js b/_nativeCreate.js index 27b476bc5..fb591e3c3 100644 --- a/_nativeCreate.js +++ b/_nativeCreate.js @@ -1,6 +1,6 @@ import getNative from './_getNative.js'; /* Built-in method references that are verified to be native. */ -var nativeCreate = getNative(Object, 'create'); +const nativeCreate = getNative(Object, 'create'); export default nativeCreate; diff --git a/_nativeKeys.js b/_nativeKeys.js index 2ec8ec6b5..f144985f7 100644 --- a/_nativeKeys.js +++ b/_nativeKeys.js @@ -1,6 +1,6 @@ import overArg from './_overArg.js'; /* Built-in method references for those with the same name as other `lodash` methods. */ -var nativeKeys = overArg(Object.keys, Object); +const nativeKeys = overArg(Object.keys, Object); export default nativeKeys; diff --git a/_nativeKeysIn.js b/_nativeKeysIn.js index 94eda99e0..e01e2ceca 100644 --- a/_nativeKeysIn.js +++ b/_nativeKeysIn.js @@ -8,9 +8,9 @@ * @returns {Array} Returns the array of property names. */ function nativeKeysIn(object) { - var result = []; + const result = []; if (object != null) { - for (var key in Object(object)) { + for (const key in Object(object)) { result.push(key); } } diff --git a/_nodeUtil.js b/_nodeUtil.js index 7a45760a5..544a212c5 100644 --- a/_nodeUtil.js +++ b/_nodeUtil.js @@ -1,19 +1,19 @@ import freeGlobal from './_freeGlobal.js'; /** Detect free variable `exports`. */ -var freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports; +const freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports; /** Detect free variable `module`. */ -var freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module; +const freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module; /** Detect the popular CommonJS extension `module.exports`. */ -var moduleExports = freeModule && freeModule.exports === freeExports; +const moduleExports = freeModule && freeModule.exports === freeExports; /** Detect free variable `process` from Node.js. */ -var freeProcess = moduleExports && freeGlobal.process; +const freeProcess = moduleExports && freeGlobal.process; /** Used to access faster Node.js helpers. */ -var nodeUtil = ((() => { +const nodeUtil = ((() => { try { return freeProcess && freeProcess.binding && freeProcess.binding('util'); } catch (e) {} diff --git a/_objectToString.js b/_objectToString.js index 749a5f9ca..a3e4dbd26 100644 --- a/_objectToString.js +++ b/_objectToString.js @@ -1,12 +1,12 @@ /** Used for built-in method references. */ -var objectProto = Object.prototype; +const objectProto = Object.prototype; /** * Used to resolve the * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring) * of values. */ -var nativeObjectToString = objectProto.toString; +const nativeObjectToString = objectProto.toString; /** * Converts `value` to a string using `Object.prototype.toString`. diff --git a/_overRest.js b/_overRest.js index f4f79cb6e..0634b987e 100644 --- a/_overRest.js +++ b/_overRest.js @@ -1,7 +1,7 @@ import apply from './_apply.js'; /* Built-in method references for those with the same name as other `lodash` methods. */ -var nativeMax = Math.max; +const nativeMax = Math.max; /** * A specialized version of `baseRest` which transforms the rest array. @@ -15,16 +15,16 @@ var nativeMax = Math.max; function overRest(func, start, transform) { start = nativeMax(start === undefined ? (func.length - 1) : start, 0); return function() { - var args = arguments, - index = -1, - length = nativeMax(args.length - start, 0), - array = Array(length); + const args = arguments; + let index = -1; + const length = nativeMax(args.length - start, 0); + const array = Array(length); while (++index < length) { array[index] = args[start + index]; } index = -1; - var otherArgs = Array(start + 1); + const otherArgs = Array(start + 1); while (++index < start) { otherArgs[index] = args[index]; } diff --git a/_reorder.js b/_reorder.js index b7ade47a6..3697ad43b 100644 --- a/_reorder.js +++ b/_reorder.js @@ -2,7 +2,7 @@ import copyArray from './_copyArray.js'; import isIndex from './_isIndex.js'; /* Built-in method references for those with the same name as other `lodash` methods. */ -var nativeMin = Math.min; +const nativeMin = Math.min; /** * Reorder `array` according to the specified indexes where the element at @@ -15,12 +15,12 @@ var nativeMin = Math.min; * @returns {Array} Returns `array`. */ function reorder(array, indexes) { - var arrLength = array.length, - length = nativeMin(indexes.length, arrLength), - oldArray = copyArray(array); + const arrLength = array.length; + let length = nativeMin(indexes.length, arrLength); + const oldArray = copyArray(array); while (length--) { - var index = indexes[length]; + const index = indexes[length]; array[length] = isIndex(index, arrLength) ? oldArray[index] : undefined; } return array; diff --git a/_replaceHolders.js b/_replaceHolders.js index e63605416..3c36bc831 100644 --- a/_replaceHolders.js +++ b/_replaceHolders.js @@ -1,5 +1,5 @@ /** Used as the internal argument placeholder. */ -var PLACEHOLDER = '__lodash_placeholder__'; +const PLACEHOLDER = '__lodash_placeholder__'; /** * Replaces all `placeholder` elements in `array` with an internal placeholder @@ -11,13 +11,13 @@ var PLACEHOLDER = '__lodash_placeholder__'; * @returns {Array} Returns the new array of placeholder indexes. */ function replaceHolders(array, placeholder) { - var index = -1, - length = array.length, - resIndex = 0, - result = []; + let index = -1; + const length = array.length; + let resIndex = 0; + const result = []; while (++index < length) { - var value = array[index]; + const value = array[index]; if (value === placeholder || value === PLACEHOLDER) { array[index] = PLACEHOLDER; result[resIndex++] = index; diff --git a/_root.js b/_root.js index 281f81280..76273b4d5 100644 --- a/_root.js +++ b/_root.js @@ -1,9 +1,9 @@ import freeGlobal from './_freeGlobal.js'; /** Detect free variable `self`. */ -var freeSelf = typeof self == 'object' && self && self.Object === Object && self; +const freeSelf = typeof self == 'object' && self && self.Object === Object && self; /** Used as a reference to the global object. */ -var root = freeGlobal || freeSelf || Function('return this')(); +const root = freeGlobal || freeSelf || Function('return this')(); export default root; diff --git a/_setCacheAdd.js b/_setCacheAdd.js index d3a42d36a..23065e878 100644 --- a/_setCacheAdd.js +++ b/_setCacheAdd.js @@ -1,5 +1,5 @@ /** Used to stand-in for `undefined` hash values. */ -var HASH_UNDEFINED = '__lodash_hash_undefined__'; +const HASH_UNDEFINED = '__lodash_hash_undefined__'; /** * Adds `value` to the array cache. diff --git a/_shortOut.js b/_shortOut.js index aca9906ca..8ca719388 100644 --- a/_shortOut.js +++ b/_shortOut.js @@ -1,9 +1,9 @@ /** Used to detect hot functions by number of calls within a span of milliseconds. */ -var HOT_COUNT = 800, - HOT_SPAN = 16; +const HOT_COUNT = 800; +const HOT_SPAN = 16; /* Built-in method references for those with the same name as other `lodash` methods. */ -var nativeNow = Date.now; +const nativeNow = Date.now; /** * Creates a function that'll short out and invoke `identity` instead @@ -15,12 +15,12 @@ var nativeNow = Date.now; * @returns {Function} Returns the new shortable function. */ function shortOut(func) { - var count = 0, - lastCalled = 0; + let count = 0; + let lastCalled = 0; return function(...args) { - var stamp = nativeNow(), - remaining = HOT_SPAN - (stamp - lastCalled); + const stamp = nativeNow(); + const remaining = HOT_SPAN - (stamp - lastCalled); lastCalled = stamp; if (remaining > 0) { diff --git a/_stackDelete.js b/_stackDelete.js index c3df897c0..1f6cfbba4 100644 --- a/_stackDelete.js +++ b/_stackDelete.js @@ -8,8 +8,8 @@ * @returns {boolean} Returns `true` if the entry was removed, else `false`. */ function stackDelete(key) { - var data = this.__data__, - result = data['delete'](key); + const data = this.__data__; + const result = data['delete'](key); this.size = data.size; return result; diff --git a/_stackSet.js b/_stackSet.js index a85af6cfe..b983616e4 100644 --- a/_stackSet.js +++ b/_stackSet.js @@ -3,7 +3,7 @@ import Map from './_Map.js'; import MapCache from './_MapCache.js'; /** Used as the size to enable large array optimizations. */ -var LARGE_ARRAY_SIZE = 200; +const LARGE_ARRAY_SIZE = 200; /** * Sets the stack `key` to `value`. @@ -16,9 +16,9 @@ var LARGE_ARRAY_SIZE = 200; * @returns {Object} Returns the stack cache instance. */ function stackSet(key, value) { - var data = this.__data__; + let data = this.__data__; if (data instanceof ListCache) { - var pairs = data.__data__; + const pairs = data.__data__; if (!Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) { pairs.push([key, value]); this.size = ++data.size; diff --git a/_strictIndexOf.js b/_strictIndexOf.js index 0dfad1ec9..6dd3b9791 100644 --- a/_strictIndexOf.js +++ b/_strictIndexOf.js @@ -9,8 +9,8 @@ * @returns {number} Returns the index of the matched value, else `-1`. */ function strictIndexOf(array, value, fromIndex) { - var index = fromIndex - 1, - length = array.length; + let index = fromIndex - 1; + const length = array.length; while (++index < length) { if (array[index] === value) { diff --git a/_strictLastIndexOf.js b/_strictLastIndexOf.js index 6ddf04ccf..e2f38a428 100644 --- a/_strictLastIndexOf.js +++ b/_strictLastIndexOf.js @@ -9,7 +9,7 @@ * @returns {number} Returns the index of the matched value, else `-1`. */ function strictLastIndexOf(array, value, fromIndex) { - var index = fromIndex + 1; + let index = fromIndex + 1; while (index--) { if (array[index] === value) { return index; diff --git a/_stringToPath.js b/_stringToPath.js index 01f37112e..ecf5b1705 100644 --- a/_stringToPath.js +++ b/_stringToPath.js @@ -1,11 +1,10 @@ import memoizeCapped from './_memoizeCapped.js'; /** Used to match property names within property paths. */ -var reLeadingDot = /^\./, - rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g; +const reLeadingDot = /^\./, rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g; /** Used to match backslashes in property paths. */ -var reEscapeChar = /\\(\\)?/g; +const reEscapeChar = /\\(\\)?/g; /** * Converts `string` to a property path array. @@ -14,8 +13,8 @@ var reEscapeChar = /\\(\\)?/g; * @param {string} string The string to convert. * @returns {Array} Returns the property path array. */ -var stringToPath = memoizeCapped(string => { - var result = []; +const stringToPath = memoizeCapped(string => { + const result = []; if (reLeadingDot.test(string)) { result.push(''); } diff --git a/_toKey.js b/_toKey.js index 66d4630f0..a2d23df8e 100644 --- a/_toKey.js +++ b/_toKey.js @@ -1,7 +1,7 @@ import isSymbol from './isSymbol.js'; /** Used as references for various `Number` constants. */ -var INFINITY = 1 / 0; +const INFINITY = 1 / 0; /** * Converts `value` to a string key if it's not a string or symbol. diff --git a/_toSource.js b/_toSource.js index c1527cfa4..9da9b29c8 100644 --- a/_toSource.js +++ b/_toSource.js @@ -1,8 +1,8 @@ /** Used for built-in method references. */ -var funcProto = Function.prototype; +const funcProto = Function.prototype; /** Used to resolve the decompiled source of functions. */ -var funcToString = funcProto.toString; +const funcToString = funcProto.toString; /** * Converts `func` to its source code. diff --git a/_unescapeHtmlChar.js b/_unescapeHtmlChar.js index e1876cc04..1991b6246 100644 --- a/_unescapeHtmlChar.js +++ b/_unescapeHtmlChar.js @@ -1,7 +1,7 @@ import basePropertyOf from './_basePropertyOf.js'; /** Used to map HTML entities to characters. */ -var htmlUnescapes = { +const htmlUnescapes = { '&': '&', '<': '<', '>': '>', @@ -16,6 +16,6 @@ var htmlUnescapes = { * @param {string} chr The matched character to unescape. * @returns {string} Returns the unescaped character. */ -var unescapeHtmlChar = basePropertyOf(htmlUnescapes); +const unescapeHtmlChar = basePropertyOf(htmlUnescapes); export default unescapeHtmlChar; diff --git a/_updateWrapDetails.js b/_updateWrapDetails.js index 9e009e9c7..2dacc0b31 100644 --- a/_updateWrapDetails.js +++ b/_updateWrapDetails.js @@ -2,18 +2,18 @@ import arrayEach from './_arrayEach.js'; import arrayIncludes from './_arrayIncludes.js'; /** Used to compose bitmasks for function metadata. */ -var WRAP_BIND_FLAG = 1, - WRAP_BIND_KEY_FLAG = 2, - WRAP_CURRY_FLAG = 8, - WRAP_CURRY_RIGHT_FLAG = 16, - WRAP_PARTIAL_FLAG = 32, - WRAP_PARTIAL_RIGHT_FLAG = 64, - WRAP_ARY_FLAG = 128, - WRAP_REARG_FLAG = 256, - WRAP_FLIP_FLAG = 512; +const WRAP_BIND_FLAG = 1; +const WRAP_BIND_KEY_FLAG = 2; +const WRAP_CURRY_FLAG = 8; +const WRAP_CURRY_RIGHT_FLAG = 16; +const WRAP_PARTIAL_FLAG = 32; +const WRAP_PARTIAL_RIGHT_FLAG = 64; +const WRAP_ARY_FLAG = 128; +const WRAP_REARG_FLAG = 256; +const WRAP_FLIP_FLAG = 512; /** Used to associate wrap methods with their bit flags. */ -var wrapFlags = [ +const wrapFlags = [ ['ary', WRAP_ARY_FLAG], ['bind', WRAP_BIND_FLAG], ['bindKey', WRAP_BIND_KEY_FLAG], @@ -35,7 +35,7 @@ var wrapFlags = [ */ function updateWrapDetails(details, bitmask) { arrayEach(wrapFlags, pair => { - var value = `_.${ pair[0] }`; + const value = `_.${ pair[0] }`; if ((bitmask & pair[1]) && !arrayIncludes(details, value)) { details.push(value); } diff --git a/_wrapperClone.js b/_wrapperClone.js index 8d0d73036..a868302a7 100644 --- a/_wrapperClone.js +++ b/_wrapperClone.js @@ -13,7 +13,7 @@ function wrapperClone(wrapper) { if (wrapper instanceof LazyWrapper) { return wrapper.clone(); } - var result = new LodashWrapper(wrapper.__wrapped__, wrapper.__chain__); + const result = new LodashWrapper(wrapper.__wrapped__, wrapper.__chain__); result.__actions__ = copyArray(wrapper.__actions__); result.__index__ = wrapper.__index__; result.__values__ = wrapper.__values__; diff --git a/add.js b/add.js index 8531113da..4df7996c9 100644 --- a/add.js +++ b/add.js @@ -15,6 +15,6 @@ import createMathOperation from './_createMathOperation.js'; * _.add(6, 4); * // => 10 */ -var add = createMathOperation((augend, addend) => augend + addend, 0); +const add = createMathOperation((augend, addend) => augend + addend, 0); export default add; diff --git a/after.js b/after.js index 8cf7c20a7..b6b246160 100644 --- a/after.js +++ b/after.js @@ -1,7 +1,7 @@ import toInteger from './toInteger.js'; /** Error message constants. */ -var FUNC_ERROR_TEXT = 'Expected a function'; +const FUNC_ERROR_TEXT = 'Expected a function'; /** * The opposite of `_.before`; this method creates a function that invokes diff --git a/ary.js b/ary.js index eb64a45a3..48b124ba4 100644 --- a/ary.js +++ b/ary.js @@ -1,7 +1,7 @@ import createWrap from './_createWrap.js'; /** Used to compose bitmasks for function metadata. */ -var WRAP_ARY_FLAG = 128; +const WRAP_ARY_FLAG = 128; /** * Creates a function that invokes `func`, with up to `n` arguments, diff --git a/assignIn.js b/assignIn.js index 8ca13870f..205004511 100644 --- a/assignIn.js +++ b/assignIn.js @@ -33,7 +33,7 @@ import keysIn from './keysIn.js'; * _.assignIn({ 'a': 0 }, new Foo, new Bar); * // => { 'a': 1, 'b': 2, 'c': 3, 'd': 4 } */ -var assignIn = createAssigner((object, source) => { +const assignIn = createAssigner((object, source) => { copyObject(source, keysIn(source), object); }); diff --git a/assignInWith.js b/assignInWith.js index 51d646a54..5ca2b8577 100644 --- a/assignInWith.js +++ b/assignInWith.js @@ -31,7 +31,7 @@ import keysIn from './keysIn.js'; * defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 }); * // => { 'a': 1, 'b': 2 } */ -var assignInWith = createAssigner((object, source, srcIndex, customizer) => { +const assignInWith = createAssigner((object, source, srcIndex, customizer) => { copyObject(source, keysIn(source), object, customizer); }); diff --git a/assignWith.js b/assignWith.js index 0e815896f..5cc76397a 100644 --- a/assignWith.js +++ b/assignWith.js @@ -30,7 +30,7 @@ import keys from './keys.js'; * defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 }); * // => { 'a': 1, 'b': 2 } */ -var assignWith = createAssigner((object, source, srcIndex, customizer) => { +const assignWith = createAssigner((object, source, srcIndex, customizer) => { copyObject(source, keys(source), object, customizer); }); diff --git a/at.js b/at.js index 6475c67f6..aa69cc017 100644 --- a/at.js +++ b/at.js @@ -18,6 +18,6 @@ import flatRest from './_flatRest.js'; * _.at(object, ['a[0].b.c', 'a[1]']); * // => [3, 4] */ -var at = flatRest(baseAt); +const at = flatRest(baseAt); export default at; diff --git a/attempt.js b/attempt.js index b7e73b736..f297e9c6c 100644 --- a/attempt.js +++ b/attempt.js @@ -24,7 +24,7 @@ import isError from './isError.js'; * elements = []; * } */ -var attempt = baseRest((func, args) => { +const attempt = baseRest((func, args) => { try { return apply(func, undefined, args); } catch (e) { diff --git a/before.js b/before.js index 152c10700..d4391c165 100644 --- a/before.js +++ b/before.js @@ -1,7 +1,7 @@ import toInteger from './toInteger.js'; /** Error message constants. */ -var FUNC_ERROR_TEXT = 'Expected a function'; +const FUNC_ERROR_TEXT = 'Expected a function'; /** * Creates a function that invokes `func`, with the `this` binding and arguments @@ -21,7 +21,7 @@ var FUNC_ERROR_TEXT = 'Expected a function'; * // => Allows adding up to 4 contacts to the list. */ function before(n, func) { - var result; + let result; if (typeof func != 'function') { throw new TypeError(FUNC_ERROR_TEXT); } diff --git a/bind.js b/bind.js index 37cd602bb..8031ae9ff 100644 --- a/bind.js +++ b/bind.js @@ -4,8 +4,8 @@ import getHolder from './_getHolder.js'; import replaceHolders from './_replaceHolders.js'; /** Used to compose bitmasks for function metadata. */ -var WRAP_BIND_FLAG = 1, - WRAP_PARTIAL_FLAG = 32; +const WRAP_BIND_FLAG = 1; +const WRAP_PARTIAL_FLAG = 32; /** * Creates a function that invokes `func` with the `this` binding of `thisArg` @@ -42,10 +42,11 @@ var WRAP_BIND_FLAG = 1, * bound('hi'); * // => 'hi fred!' */ -var bind = baseRest((func, thisArg, partials) => { - var bitmask = WRAP_BIND_FLAG; +const bind = baseRest((func, thisArg, partials) => { + let holders; + let bitmask = WRAP_BIND_FLAG; if (partials.length) { - var holders = replaceHolders(partials, getHolder(bind)); + holders = replaceHolders(partials, getHolder(bind)); bitmask |= WRAP_PARTIAL_FLAG; } return createWrap(func, bitmask, thisArg, partials, holders); diff --git a/bindAll.js b/bindAll.js index 0e4dcb4a9..1bcfe55a7 100644 --- a/bindAll.js +++ b/bindAll.js @@ -30,7 +30,7 @@ import toKey from './_toKey.js'; * jQuery(element).on('click', view.click); * // => Logs 'clicked docs' when clicked. */ -var bindAll = flatRest((object, methodNames) => { +const bindAll = flatRest((object, methodNames) => { arrayEach(methodNames, key => { key = toKey(key); baseAssignValue(object, key, bind(object[key], object)); diff --git a/bindKey.js b/bindKey.js index a7c02cf0b..0d56eba91 100644 --- a/bindKey.js +++ b/bindKey.js @@ -4,9 +4,9 @@ import getHolder from './_getHolder.js'; import replaceHolders from './_replaceHolders.js'; /** Used to compose bitmasks for function metadata. */ -var WRAP_BIND_FLAG = 1, - WRAP_BIND_KEY_FLAG = 2, - WRAP_PARTIAL_FLAG = 32; +const WRAP_BIND_FLAG = 1; +const WRAP_BIND_KEY_FLAG = 2; +const WRAP_PARTIAL_FLAG = 32; /** * Creates a function that invokes the method at `object[key]` with `partials` @@ -53,10 +53,11 @@ var WRAP_BIND_FLAG = 1, * bound('hi'); * // => 'hiya fred!' */ -var bindKey = baseRest((object, key, partials) => { - var bitmask = WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG; +const bindKey = baseRest((object, key, partials) => { + let holders; + let bitmask = WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG; if (partials.length) { - var holders = replaceHolders(partials, getHolder(bindKey)); + holders = replaceHolders(partials, getHolder(bindKey)); bitmask |= WRAP_PARTIAL_FLAG; } return createWrap(key, bitmask, object, partials, holders); diff --git a/camelCase.js b/camelCase.js index 629e12379..ed00b9528 100644 --- a/camelCase.js +++ b/camelCase.js @@ -21,7 +21,7 @@ import createCompounder from './_createCompounder.js'; * _.camelCase('__FOO_BAR__'); * // => 'fooBar' */ -var camelCase = createCompounder((result, word, index) => { +const camelCase = createCompounder((result, word, index) => { word = word.toLowerCase(); return result + (index ? capitalize(word) : word); }); diff --git a/castArray.js b/castArray.js index 7108bdb17..db52122a7 100644 --- a/castArray.js +++ b/castArray.js @@ -37,7 +37,7 @@ function castArray(...args) { if (!args.length) { return []; } - var value = args[0]; + const value = args[0]; return isArray(value) ? value : [value]; } diff --git a/ceil.js b/ceil.js index e86212a47..bd91b9db8 100644 --- a/ceil.js +++ b/ceil.js @@ -21,6 +21,6 @@ import createRound from './_createRound.js'; * _.ceil(6040, -2); * // => 6100 */ -var ceil = createRound('ceil'); +const ceil = createRound('ceil'); export default ceil; diff --git a/chunk.js b/chunk.js index 70dd98333..c240e3605 100644 --- a/chunk.js +++ b/chunk.js @@ -3,8 +3,8 @@ import isIterateeCall from './_isIterateeCall.js'; import toInteger from './toInteger.js'; /* Built-in method references for those with the same name as other `lodash` methods. */ -var nativeCeil = Math.ceil, - nativeMax = Math.max; +const nativeCeil = Math.ceil; +const nativeMax = Math.max; /** * Creates an array of elements split into groups the length of `size`. @@ -33,13 +33,13 @@ function chunk(array, size, guard) { } else { size = nativeMax(toInteger(size), 0); } - var length = array == null ? 0 : array.length; + const length = array == null ? 0 : array.length; if (!length || size < 1) { return []; } - var index = 0, - resIndex = 0, - result = Array(nativeCeil(length / size)); + let index = 0; + let resIndex = 0; + const result = Array(nativeCeil(length / size)); while (index < length) { result[resIndex++] = baseSlice(array, index, (index += size)); diff --git a/clone.js b/clone.js index b14701211..6efe5ac6f 100644 --- a/clone.js +++ b/clone.js @@ -1,7 +1,7 @@ import baseClone from './_baseClone.js'; /** Used to compose bitmasks for cloning. */ -var CLONE_SYMBOLS_FLAG = 4; +const CLONE_SYMBOLS_FLAG = 4; /** * Creates a shallow clone of `value`. diff --git a/cloneDeep.js b/cloneDeep.js index 44d403d77..c124cb7fe 100644 --- a/cloneDeep.js +++ b/cloneDeep.js @@ -1,8 +1,8 @@ import baseClone from './_baseClone.js'; /** Used to compose bitmasks for cloning. */ -var CLONE_DEEP_FLAG = 1, - CLONE_SYMBOLS_FLAG = 4; +const CLONE_DEEP_FLAG = 1; +const CLONE_SYMBOLS_FLAG = 4; /** * This method is like `_.clone` except that it recursively clones `value`. diff --git a/cloneDeepWith.js b/cloneDeepWith.js index 8cd788588..45373861f 100644 --- a/cloneDeepWith.js +++ b/cloneDeepWith.js @@ -1,8 +1,8 @@ import baseClone from './_baseClone.js'; /** Used to compose bitmasks for cloning. */ -var CLONE_DEEP_FLAG = 1, - CLONE_SYMBOLS_FLAG = 4; +const CLONE_DEEP_FLAG = 1; +const CLONE_SYMBOLS_FLAG = 4; /** * This method is like `_.cloneWith` except that it recursively clones `value`. diff --git a/cloneWith.js b/cloneWith.js index c900df14c..326a3d2a4 100644 --- a/cloneWith.js +++ b/cloneWith.js @@ -1,7 +1,7 @@ import baseClone from './_baseClone.js'; /** Used to compose bitmasks for cloning. */ -var CLONE_SYMBOLS_FLAG = 4; +const CLONE_SYMBOLS_FLAG = 4; /** * This method is like `_.clone` except that it accepts `customizer` which diff --git a/compact.js b/compact.js index b644f2804..d6596680b 100644 --- a/compact.js +++ b/compact.js @@ -14,13 +14,13 @@ * // => [1, 2, 3] */ function compact(array) { - var index = -1, - length = array == null ? 0 : array.length, - resIndex = 0, - result = []; + let index = -1; + const length = array == null ? 0 : array.length; + let resIndex = 0; + const result = []; while (++index < length) { - var value = array[index]; + const value = array[index]; if (value) { result[resIndex++] = value; } diff --git a/concat.js b/concat.js index 4f598c34d..b1cff51e9 100644 --- a/concat.js +++ b/concat.js @@ -26,13 +26,13 @@ import isArray from './isArray.js'; * // => [1] */ function concat() { - var length = arguments.length; + const length = arguments.length; if (!length) { return []; } - var args = Array(length - 1), - array = arguments[0], - index = length; + const args = Array(length - 1); + const array = arguments[0]; + let index = length; while (index--) { args[index - 1] = arguments[index]; diff --git a/cond.js b/cond.js index ab0cfab0b..a874c0c0f 100644 --- a/cond.js +++ b/cond.js @@ -4,7 +4,7 @@ import baseIteratee from './_baseIteratee.js'; import baseRest from './_baseRest.js'; /** Error message constants. */ -var FUNC_ERROR_TEXT = 'Expected a function'; +const FUNC_ERROR_TEXT = 'Expected a function'; /** * Creates a function that iterates over `pairs` and invokes the corresponding @@ -36,8 +36,8 @@ var FUNC_ERROR_TEXT = 'Expected a function'; * // => 'no match' */ function cond(pairs) { - var length = pairs == null ? 0 : pairs.length, - toIteratee = baseIteratee; + const length = pairs == null ? 0 : pairs.length; + const toIteratee = baseIteratee; pairs = !length ? [] : arrayMap(pairs, pair => { if (typeof pair[1] != 'function') { @@ -47,9 +47,9 @@ function cond(pairs) { }); return baseRest(function(args) { - var index = -1; + let index = -1; while (++index < length) { - var pair = pairs[index]; + const pair = pairs[index]; if (apply(pair[0], this, args)) { return apply(pair[1], this, args); } diff --git a/conforms.js b/conforms.js index 2fb1ebe91..8cdf350ce 100644 --- a/conforms.js +++ b/conforms.js @@ -2,7 +2,7 @@ import baseClone from './_baseClone.js'; import baseConforms from './_baseConforms.js'; /** Used to compose bitmasks for cloning. */ -var CLONE_DEEP_FLAG = 1; +const CLONE_DEEP_FLAG = 1; /** * Creates a function that invokes the predicate properties of `source` with diff --git a/countBy.js b/countBy.js index 6106887e1..98def343e 100644 --- a/countBy.js +++ b/countBy.js @@ -2,10 +2,10 @@ import baseAssignValue from './_baseAssignValue.js'; import createAggregator from './_createAggregator.js'; /** Used for built-in method references. */ -var objectProto = Object.prototype; +const objectProto = Object.prototype; /** Used to check objects for own properties. */ -var hasOwnProperty = objectProto.hasOwnProperty; +const hasOwnProperty = objectProto.hasOwnProperty; /** * Creates an object composed of keys generated from the results of running @@ -29,7 +29,7 @@ var hasOwnProperty = objectProto.hasOwnProperty; * _.countBy(['one', 'two', 'three'], 'length'); * // => { '3': 2, '5': 1 } */ -var countBy = createAggregator((result, value, key) => { +const countBy = createAggregator((result, value, key) => { if (hasOwnProperty.call(result, key)) { ++result[key]; } else { diff --git a/create.js b/create.js index 5a9aa3702..5585d35e3 100644 --- a/create.js +++ b/create.js @@ -36,7 +36,7 @@ import baseCreate from './_baseCreate.js'; * // => true */ function create(prototype, properties) { - var result = baseCreate(prototype); + const result = baseCreate(prototype); return properties == null ? result : baseAssign(result, properties); } diff --git a/curry.js b/curry.js index 953102f66..45bec872f 100644 --- a/curry.js +++ b/curry.js @@ -1,7 +1,7 @@ import createWrap from './_createWrap.js'; /** Used to compose bitmasks for function metadata. */ -var WRAP_CURRY_FLAG = 8; +const WRAP_CURRY_FLAG = 8; /** * Creates a function that accepts arguments of `func` and either invokes @@ -46,7 +46,7 @@ var WRAP_CURRY_FLAG = 8; */ function curry(func, arity, guard) { arity = guard ? undefined : arity; - var result = createWrap(func, WRAP_CURRY_FLAG, undefined, undefined, undefined, undefined, undefined, arity); + const result = createWrap(func, WRAP_CURRY_FLAG, undefined, undefined, undefined, undefined, undefined, arity); result.placeholder = curry.placeholder; return result; } diff --git a/curryRight.js b/curryRight.js index 5cc33aac6..99e30f6ff 100644 --- a/curryRight.js +++ b/curryRight.js @@ -1,7 +1,7 @@ import createWrap from './_createWrap.js'; /** Used to compose bitmasks for function metadata. */ -var WRAP_CURRY_RIGHT_FLAG = 16; +const WRAP_CURRY_RIGHT_FLAG = 16; /** * This method is like `_.curry` except that arguments are applied to `func` @@ -43,7 +43,7 @@ var WRAP_CURRY_RIGHT_FLAG = 16; */ function curryRight(func, arity, guard) { arity = guard ? undefined : arity; - var result = createWrap(func, WRAP_CURRY_RIGHT_FLAG, undefined, undefined, undefined, undefined, undefined, arity); + const result = createWrap(func, WRAP_CURRY_RIGHT_FLAG, undefined, undefined, undefined, undefined, undefined, arity); result.placeholder = curryRight.placeholder; return result; } diff --git a/debounce.js b/debounce.js index ec8171936..222a1e6ad 100644 --- a/debounce.js +++ b/debounce.js @@ -3,11 +3,11 @@ import now from './now.js'; import toNumber from './toNumber.js'; /** Error message constants. */ -var FUNC_ERROR_TEXT = 'Expected a function'; +const FUNC_ERROR_TEXT = 'Expected a function'; /* Built-in method references for those with the same name as other `lodash` methods. */ -var nativeMax = Math.max, - nativeMin = Math.min; +const nativeMax = Math.max; +const nativeMin = Math.min; /** * Creates a debounced function that delays invoking `func` until after `wait` @@ -64,16 +64,17 @@ var nativeMax = Math.max, * jQuery(window).on('popstate', debounced.cancel); */ function debounce(func, wait, options) { - var lastArgs, + let lastArgs, lastThis, maxWait, result, timerId, - lastCallTime, - lastInvokeTime = 0, - leading = false, - maxing = false, - trailing = true; + lastCallTime; + + let lastInvokeTime = 0; + let leading = false; + let maxing = false; + let trailing = true; if (typeof func != 'function') { throw new TypeError(FUNC_ERROR_TEXT); @@ -87,8 +88,8 @@ function debounce(func, wait, options) { } function invokeFunc(time) { - var args = lastArgs, - thisArg = lastThis; + const args = lastArgs; + const thisArg = lastThis; lastArgs = lastThis = undefined; lastInvokeTime = time; @@ -106,16 +107,16 @@ function debounce(func, wait, options) { } function remainingWait(time) { - var timeSinceLastCall = time - lastCallTime, - timeSinceLastInvoke = time - lastInvokeTime, - result = wait - timeSinceLastCall; + const timeSinceLastCall = time - lastCallTime; + const timeSinceLastInvoke = time - lastInvokeTime; + const result = wait - timeSinceLastCall; return maxing ? nativeMin(result, maxWait - timeSinceLastInvoke) : result; } function shouldInvoke(time) { - var timeSinceLastCall = time - lastCallTime, - timeSinceLastInvoke = time - lastInvokeTime; + const timeSinceLastCall = time - lastCallTime; + const timeSinceLastInvoke = time - lastInvokeTime; // Either this is the first call, activity has stopped and we're at the // trailing edge, the system time has gone backwards and we're treating @@ -125,7 +126,7 @@ function debounce(func, wait, options) { } function timerExpired() { - var time = now(); + const time = now(); if (shouldInvoke(time)) { return trailingEdge(time); } @@ -158,8 +159,8 @@ function debounce(func, wait, options) { } function debounced(...args) { - var time = now(), - isInvoking = shouldInvoke(time); + const time = now(); + const isInvoking = shouldInvoke(time); lastArgs = args; lastThis = this; diff --git a/defaults.js b/defaults.js index 4552a4905..7a0c949b9 100644 --- a/defaults.js +++ b/defaults.js @@ -24,7 +24,7 @@ import customDefaultsAssignIn from './_customDefaultsAssignIn.js'; * _.defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 }); * // => { 'a': 1, 'b': 2 } */ -var defaults = baseRest(args => { +const defaults = baseRest(args => { args.push(undefined, customDefaultsAssignIn); return apply(assignInWith, undefined, args); }); diff --git a/defaultsDeep.js b/defaultsDeep.js index fc6528150..d972ea78a 100644 --- a/defaultsDeep.js +++ b/defaultsDeep.js @@ -22,7 +22,7 @@ import mergeWith from './mergeWith.js'; * _.defaultsDeep({ 'a': { 'b': 2 } }, { 'a': { 'b': 1, 'c': 3 } }); * // => { 'a': { 'b': 2, 'c': 3 } } */ -var defaultsDeep = baseRest(args => { +const defaultsDeep = baseRest(args => { args.push(undefined, customDefaultsMerge); return apply(mergeWith, undefined, args); }); diff --git a/defer.js b/defer.js index 1a6974a85..e08dece0f 100644 --- a/defer.js +++ b/defer.js @@ -1,5 +1,4 @@ import baseDelay from './_baseDelay.js'; -import baseRest from './_baseRest.js'; /** * Defers invoking the `func` until the current call stack has cleared. Any @@ -19,6 +18,8 @@ import baseRest from './_baseRest.js'; * }, 'deferred'); * // => Logs 'deferred' after one millisecond. */ -var defer = baseRest((func, args) => baseDelay(func, 1, args)); +function defer(func, ...args) { + return baseDelay(func, 1, args); +} export default defer; diff --git a/delay.js b/delay.js index 681de4b07..9356a90b8 100644 --- a/delay.js +++ b/delay.js @@ -1,5 +1,4 @@ import baseDelay from './_baseDelay.js'; -import baseRest from './_baseRest.js'; import toNumber from './toNumber.js'; /** @@ -21,6 +20,8 @@ import toNumber from './toNumber.js'; * }, 1000, 'later'); * // => Logs 'later' after one second. */ -var delay = baseRest((func, wait, args) => baseDelay(func, toNumber(wait) || 0, args)); +function delay(func, wait, ...args) { + return baseDelay(func, toNumber(wait) || 0, args); +} export default delay; diff --git a/difference.js b/difference.js index 2ce272053..49547686e 100644 --- a/difference.js +++ b/difference.js @@ -1,6 +1,5 @@ import baseDifference from './_baseDifference.js'; import baseFlatten from './_baseFlatten.js'; -import baseRest from './_baseRest.js'; import isArrayLikeObject from './isArrayLikeObject.js'; /** @@ -24,8 +23,10 @@ import isArrayLikeObject from './isArrayLikeObject.js'; * _.difference([2, 1], [2, 3]); * // => [1] */ -var difference = baseRest((array, values) => isArrayLikeObject(array) - ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true)) - : []); +function difference(array, ...values) { + return isArrayLikeObject(array) + ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true)) + : []; +} export default difference; diff --git a/differenceBy.js b/differenceBy.js index acc58d438..d0629aee4 100644 --- a/differenceBy.js +++ b/differenceBy.js @@ -1,7 +1,6 @@ import baseDifference from './_baseDifference.js'; import baseFlatten from './_baseFlatten.js'; import baseIteratee from './_baseIteratee.js'; -import baseRest from './_baseRest.js'; import isArrayLikeObject from './isArrayLikeObject.js'; import last from './last.js'; @@ -31,14 +30,14 @@ import last from './last.js'; * _.differenceBy([{ 'x': 2 }, { 'x': 1 }], [{ 'x': 1 }], 'x'); * // => [{ 'x': 2 }] */ -var differenceBy = baseRest((array, values) => { - var iteratee = last(values); +function differenceBy(array, ...values) { + let iteratee = last(values); if (isArrayLikeObject(iteratee)) { iteratee = undefined; } return isArrayLikeObject(array) ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true), baseIteratee(iteratee, 2)) : []; -}); +} export default differenceBy; diff --git a/differenceWith.js b/differenceWith.js index 4ac04c4a2..0cd048c77 100644 --- a/differenceWith.js +++ b/differenceWith.js @@ -1,6 +1,5 @@ import baseDifference from './_baseDifference.js'; import baseFlatten from './_baseFlatten.js'; -import baseRest from './_baseRest.js'; import isArrayLikeObject from './isArrayLikeObject.js'; import last from './last.js'; @@ -27,14 +26,14 @@ import last from './last.js'; * _.differenceWith(objects, [{ 'x': 1, 'y': 2 }], _.isEqual); * // => [{ 'x': 2, 'y': 1 }] */ -var differenceWith = baseRest((array, values) => { - var comparator = last(values); +function differenceWith(array, ...values) { + let comparator = last(values); if (isArrayLikeObject(comparator)) { comparator = undefined; } return isArrayLikeObject(array) ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true), undefined, comparator) : []; -}); +} export default differenceWith; diff --git a/divide.js b/divide.js index b7f33eefe..b86a6acea 100644 --- a/divide.js +++ b/divide.js @@ -15,6 +15,6 @@ import createMathOperation from './_createMathOperation.js'; * _.divide(6, 4); * // => 1.5 */ -var divide = createMathOperation((dividend, divisor) => dividend / divisor, 1); +const divide = createMathOperation((dividend, divisor) => dividend / divisor, 1); export default divide; diff --git a/drop.js b/drop.js index 03e59a922..26c430a7e 100644 --- a/drop.js +++ b/drop.js @@ -27,7 +27,7 @@ import toInteger from './toInteger.js'; * // => [1, 2, 3] */ function drop(array, n, guard) { - var length = array == null ? 0 : array.length; + const length = array == null ? 0 : array.length; if (!length) { return []; } diff --git a/dropRight.js b/dropRight.js index 642f241b0..1814fda48 100644 --- a/dropRight.js +++ b/dropRight.js @@ -27,7 +27,7 @@ import toInteger from './toInteger.js'; * // => [1, 2, 3] */ function dropRight(array, n, guard) { - var length = array == null ? 0 : array.length; + const length = array == null ? 0 : array.length; if (!length) { return []; } diff --git a/endsWith.js b/endsWith.js index 1554a6e40..c3dba1628 100644 --- a/endsWith.js +++ b/endsWith.js @@ -30,12 +30,12 @@ function endsWith(string, target, position) { string = toString(string); target = baseToString(target); - var length = string.length; + const length = string.length; position = position === undefined ? length : baseClamp(toInteger(position), 0, length); - var end = position; + const end = position; position -= target.length; return position >= 0 && string.slice(position, end) == target; } diff --git a/escape.js b/escape.js index 6c720aeee..e0219fee8 100644 --- a/escape.js +++ b/escape.js @@ -2,8 +2,8 @@ import escapeHtmlChar from './_escapeHtmlChar.js'; import toString from './toString.js'; /** Used to match HTML entities and HTML characters. */ -var reUnescapedHtml = /[&<>"']/g, - reHasUnescapedHtml = RegExp(reUnescapedHtml.source); +const reUnescapedHtml = /[&<>"']/g; +const reHasUnescapedHtml = RegExp(reUnescapedHtml.source); /** * Converts the characters "&", "<", ">", '"', and "'" in `string` to their diff --git a/escapeRegExp.js b/escapeRegExp.js index 0b904ca48..6021a2181 100644 --- a/escapeRegExp.js +++ b/escapeRegExp.js @@ -4,8 +4,8 @@ import toString from './toString.js'; * Used to match `RegExp` * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns). */ -var reRegExpChar = /[\\^$.*+?()[\]{}|]/g, - reHasRegExpChar = RegExp(reRegExpChar.source); +const reRegExpChar = /[\\^$.*+?()[\]{}|]/g; +const reHasRegExpChar = RegExp(reRegExpChar.source); /** * Escapes the `RegExp` special characters "^", "$", "\", ".", "*", "+", diff --git a/every.js b/every.js index f44d02cf5..61bf5f349 100644 --- a/every.js +++ b/every.js @@ -46,7 +46,7 @@ import isIterateeCall from './_isIterateeCall.js'; * // => false */ function every(collection, predicate, guard) { - var func = isArray(collection) ? arrayEvery : baseEvery; + const func = isArray(collection) ? arrayEvery : baseEvery; if (guard && isIterateeCall(collection, predicate, guard)) { predicate = undefined; } diff --git a/fill.js b/fill.js index 42c2ba795..11fa6af52 100644 --- a/fill.js +++ b/fill.js @@ -31,7 +31,7 @@ import isIterateeCall from './_isIterateeCall.js'; * // => [4, '*', '*', 10] */ function fill(array, value, start, end) { - var length = array == null ? 0 : array.length; + const length = array == null ? 0 : array.length; if (!length) { return []; } diff --git a/filter.js b/filter.js index e45a7ba57..8c4073682 100644 --- a/filter.js +++ b/filter.js @@ -41,7 +41,7 @@ import isArray from './isArray.js'; * // => objects for ['barney'] */ function filter(collection, predicate) { - var func = isArray(collection) ? arrayFilter : baseFilter; + const func = isArray(collection) ? arrayFilter : baseFilter; return func(collection, baseIteratee(predicate, 3)); } diff --git a/find.js b/find.js index fd8de527e..d7dab9c25 100644 --- a/find.js +++ b/find.js @@ -37,6 +37,6 @@ import findIndex from './findIndex.js'; * _.find(users, 'active'); * // => object for 'barney' */ -var find = createFind(findIndex); +const find = createFind(findIndex); export default find; diff --git a/findIndex.js b/findIndex.js index c1cd7cdb3..15fa25620 100644 --- a/findIndex.js +++ b/findIndex.js @@ -3,7 +3,7 @@ import baseIteratee from './_baseIteratee.js'; import toInteger from './toInteger.js'; /* Built-in method references for those with the same name as other `lodash` methods. */ -var nativeMax = Math.max; +const nativeMax = Math.max; /** * This method is like `_.find` except that it returns the index of the first @@ -41,11 +41,11 @@ var nativeMax = Math.max; * // => 2 */ function findIndex(array, predicate, fromIndex) { - var length = array == null ? 0 : array.length; + const length = array == null ? 0 : array.length; if (!length) { return -1; } - var index = fromIndex == null ? 0 : toInteger(fromIndex); + let index = fromIndex == null ? 0 : toInteger(fromIndex); if (index < 0) { index = nativeMax(length + index, 0); } diff --git a/findLast.js b/findLast.js index 02373864e..23d408efa 100644 --- a/findLast.js +++ b/findLast.js @@ -20,6 +20,6 @@ import findLastIndex from './findLastIndex.js'; * }); * // => 3 */ -var findLast = createFind(findLastIndex); +const findLast = createFind(findLastIndex); export default findLast; diff --git a/findLastIndex.js b/findLastIndex.js index c2bb6dc1a..a17dafd57 100644 --- a/findLastIndex.js +++ b/findLastIndex.js @@ -3,8 +3,8 @@ import baseIteratee from './_baseIteratee.js'; import toInteger from './toInteger.js'; /* Built-in method references for those with the same name as other `lodash` methods. */ -var nativeMax = Math.max, - nativeMin = Math.min; +const nativeMax = Math.max; +const nativeMin = Math.min; /** * This method is like `_.findIndex` except that it iterates over elements @@ -42,11 +42,11 @@ var nativeMax = Math.max, * // => 0 */ function findLastIndex(array, predicate, fromIndex) { - var length = array == null ? 0 : array.length; + const length = array == null ? 0 : array.length; if (!length) { return -1; } - var index = length - 1; + let index = length - 1; if (fromIndex !== undefined) { index = toInteger(fromIndex); index = fromIndex < 0 diff --git a/flatMapDeep.js b/flatMapDeep.js index d33d219e4..59f54621a 100644 --- a/flatMapDeep.js +++ b/flatMapDeep.js @@ -2,7 +2,7 @@ import baseFlatten from './_baseFlatten.js'; import map from './map.js'; /** Used as references for various `Number` constants. */ -var INFINITY = 1 / 0; +const INFINITY = 1 / 0; /** * This method is like `_.flatMap` except that it recursively flattens the diff --git a/flatten.js b/flatten.js index 399b2a762..2ed713269 100644 --- a/flatten.js +++ b/flatten.js @@ -15,7 +15,7 @@ import baseFlatten from './_baseFlatten.js'; * // => [1, 2, [3, [4]], 5] */ function flatten(array) { - var length = array == null ? 0 : array.length; + const length = array == null ? 0 : array.length; return length ? baseFlatten(array, 1) : []; } diff --git a/flattenDeep.js b/flattenDeep.js index 4a7a9a98b..29dd5a401 100644 --- a/flattenDeep.js +++ b/flattenDeep.js @@ -1,7 +1,7 @@ import baseFlatten from './_baseFlatten.js'; /** Used as references for various `Number` constants. */ -var INFINITY = 1 / 0; +const INFINITY = 1 / 0; /** * Recursively flattens `array`. @@ -18,7 +18,7 @@ var INFINITY = 1 / 0; * // => [1, 2, 3, 4, 5] */ function flattenDeep(array) { - var length = array == null ? 0 : array.length; + const length = array == null ? 0 : array.length; return length ? baseFlatten(array, INFINITY) : []; } diff --git a/flattenDepth.js b/flattenDepth.js index 101dc3f0f..62fcccfd6 100644 --- a/flattenDepth.js +++ b/flattenDepth.js @@ -22,7 +22,7 @@ import toInteger from './toInteger.js'; * // => [1, 2, 3, [4], 5] */ function flattenDepth(array, depth) { - var length = array == null ? 0 : array.length; + const length = array == null ? 0 : array.length; if (!length) { return []; } diff --git a/flip.js b/flip.js index 787324c93..fa520e5b1 100644 --- a/flip.js +++ b/flip.js @@ -1,7 +1,7 @@ import createWrap from './_createWrap.js'; /** Used to compose bitmasks for function metadata. */ -var WRAP_FLIP_FLAG = 512; +const WRAP_FLIP_FLAG = 512; /** * Creates a function that invokes `func` with arguments reversed. diff --git a/floor.js b/floor.js index 7ea5394f7..56ae18d9f 100644 --- a/floor.js +++ b/floor.js @@ -21,6 +21,6 @@ import createRound from './_createRound.js'; * _.floor(4060, -2); * // => 4000 */ -var floor = createRound('floor'); +const floor = createRound('floor'); export default floor; diff --git a/flow.js b/flow.js index 0a3e633e9..3c87a8774 100644 --- a/flow.js +++ b/flow.js @@ -22,6 +22,6 @@ import createFlow from './_createFlow.js'; * addSquare(1, 2); * // => 9 */ -var flow = createFlow(); +const flow = createFlow(); export default flow; diff --git a/flowRight.js b/flowRight.js index cec0b80ef..a69c06852 100644 --- a/flowRight.js +++ b/flowRight.js @@ -21,6 +21,6 @@ import createFlow from './_createFlow.js'; * addSquare(1, 2); * // => 9 */ -var flowRight = createFlow(true); +const flowRight = createFlow(true); export default flowRight; diff --git a/forEach.js b/forEach.js index ac1310ced..15f9780f3 100644 --- a/forEach.js +++ b/forEach.js @@ -34,7 +34,7 @@ import isArray from './isArray.js'; * // => Logs 'a' then 'b' (iteration order is not guaranteed). */ function forEach(collection, iteratee) { - var func = isArray(collection) ? arrayEach : baseEach; + const func = isArray(collection) ? arrayEach : baseEach; return func(collection, castFunction(iteratee)); } diff --git a/forEachRight.js b/forEachRight.js index 924548eba..cb12c147a 100644 --- a/forEachRight.js +++ b/forEachRight.js @@ -24,7 +24,7 @@ import isArray from './isArray.js'; * // => Logs `2` then `1`. */ function forEachRight(collection, iteratee) { - var func = isArray(collection) ? arrayEachRight : baseEachRight; + const func = isArray(collection) ? arrayEachRight : baseEachRight; return func(collection, castFunction(iteratee)); } diff --git a/fromPairs.js b/fromPairs.js index 4267cfbdc..94e1d071c 100644 --- a/fromPairs.js +++ b/fromPairs.js @@ -14,12 +14,12 @@ * // => { 'a': 1, 'b': 2 } */ function fromPairs(pairs) { - var index = -1, - length = pairs == null ? 0 : pairs.length, - result = {}; + let index = -1; + const length = pairs == null ? 0 : pairs.length; + const result = {}; while (++index < length) { - var pair = pairs[index]; + const pair = pairs[index]; result[pair[0]] = pair[1]; } return result; diff --git a/get.js b/get.js index 551783500..cbd772676 100644 --- a/get.js +++ b/get.js @@ -26,7 +26,7 @@ import baseGet from './_baseGet.js'; * // => 'default' */ function get(object, path, defaultValue) { - var result = object == null ? undefined : baseGet(object, path); + const result = object == null ? undefined : baseGet(object, path); return result === undefined ? defaultValue : result; } diff --git a/groupBy.js b/groupBy.js index 472babc63..4ab3cd924 100644 --- a/groupBy.js +++ b/groupBy.js @@ -2,10 +2,10 @@ import baseAssignValue from './_baseAssignValue.js'; import createAggregator from './_createAggregator.js'; /** Used for built-in method references. */ -var objectProto = Object.prototype; +const objectProto = Object.prototype; /** Used to check objects for own properties. */ -var hasOwnProperty = objectProto.hasOwnProperty; +const hasOwnProperty = objectProto.hasOwnProperty; /** * Creates an object composed of keys generated from the results of running @@ -30,7 +30,7 @@ var hasOwnProperty = objectProto.hasOwnProperty; * _.groupBy(['one', 'two', 'three'], 'length'); * // => { '3': ['one', 'two'], '5': ['three'] } */ -var groupBy = createAggregator((result, value, key) => { +const groupBy = createAggregator((result, value, key) => { if (hasOwnProperty.call(result, key)) { result[key].push(value); } else { diff --git a/gt.js b/gt.js index 6a7227f67..f546999f0 100644 --- a/gt.js +++ b/gt.js @@ -24,6 +24,6 @@ import createRelationalOperation from './_createRelationalOperation.js'; * _.gt(1, 3); * // => false */ -var gt = createRelationalOperation(baseGt); +const gt = createRelationalOperation(baseGt); export default gt; diff --git a/gte.js b/gte.js index 9e255a820..af6dac147 100644 --- a/gte.js +++ b/gte.js @@ -23,6 +23,6 @@ import createRelationalOperation from './_createRelationalOperation.js'; * _.gte(1, 3); * // => false */ -var gte = createRelationalOperation((value, other) => value >= other); +const gte = createRelationalOperation((value, other) => value >= other); export default gte; diff --git a/includes.js b/includes.js index 7bb379384..07019243f 100644 --- a/includes.js +++ b/includes.js @@ -5,7 +5,7 @@ import toInteger from './toInteger.js'; import values from './values.js'; /* Built-in method references for those with the same name as other `lodash` methods. */ -var nativeMax = Math.max; +const nativeMax = Math.max; /** * Checks if `value` is in `collection`. If `collection` is a string, it's @@ -41,7 +41,7 @@ function includes(collection, value, fromIndex, guard) { collection = isArrayLike(collection) ? collection : values(collection); fromIndex = (fromIndex && !guard) ? toInteger(fromIndex) : 0; - var length = collection.length; + const length = collection.length; if (fromIndex < 0) { fromIndex = nativeMax(length + fromIndex, 0); } diff --git a/indexOf.js b/indexOf.js index ea3f95961..52303c80f 100644 --- a/indexOf.js +++ b/indexOf.js @@ -2,7 +2,7 @@ import baseIndexOf from './_baseIndexOf.js'; import toInteger from './toInteger.js'; /* Built-in method references for those with the same name as other `lodash` methods. */ -var nativeMax = Math.max; +const nativeMax = Math.max; /** * Gets the index at which the first occurrence of `value` is found in `array` @@ -28,11 +28,11 @@ var nativeMax = Math.max; * // => 3 */ function indexOf(array, value, fromIndex) { - var length = array == null ? 0 : array.length; + const length = array == null ? 0 : array.length; if (!length) { return -1; } - var index = fromIndex == null ? 0 : toInteger(fromIndex); + let index = fromIndex == null ? 0 : toInteger(fromIndex); if (index < 0) { index = nativeMax(length + index, 0); } diff --git a/initial.js b/initial.js index 908e5608c..890e2ca7d 100644 --- a/initial.js +++ b/initial.js @@ -15,7 +15,7 @@ import baseSlice from './_baseSlice.js'; * // => [1, 2] */ function initial(array) { - var length = array == null ? 0 : array.length; + const length = array == null ? 0 : array.length; return length ? baseSlice(array, 0, -1) : []; } diff --git a/intersection.js b/intersection.js index b236e1faf..d7b4da858 100644 --- a/intersection.js +++ b/intersection.js @@ -1,6 +1,5 @@ import arrayMap from './_arrayMap.js'; import baseIntersection from './_baseIntersection.js'; -import baseRest from './_baseRest.js'; import castArrayLikeObject from './_castArrayLikeObject.js'; /** @@ -20,11 +19,11 @@ import castArrayLikeObject from './_castArrayLikeObject.js'; * _.intersection([2, 1], [2, 3]); * // => [2] */ -var intersection = baseRest(arrays => { - var mapped = arrayMap(arrays, castArrayLikeObject); +function intersection(...arrays) { + const mapped = arrayMap(arrays, castArrayLikeObject); return (mapped.length && mapped[0] === arrays[0]) ? baseIntersection(mapped) : []; -}); +} export default intersection; diff --git a/intersectionBy.js b/intersectionBy.js index 28b36b752..794a78f4f 100644 --- a/intersectionBy.js +++ b/intersectionBy.js @@ -1,7 +1,6 @@ import arrayMap from './_arrayMap.js'; import baseIntersection from './_baseIntersection.js'; import baseIteratee from './_baseIteratee.js'; -import baseRest from './_baseRest.js'; import castArrayLikeObject from './_castArrayLikeObject.js'; import last from './last.js'; @@ -28,9 +27,9 @@ import last from './last.js'; * _.intersectionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x'); * // => [{ 'x': 1 }] */ -var intersectionBy = baseRest(arrays => { - var iteratee = last(arrays), - mapped = arrayMap(arrays, castArrayLikeObject); +function intersectionBy(...arrays) { + let iteratee = last(arrays); + const mapped = arrayMap(arrays, castArrayLikeObject); if (iteratee === last(mapped)) { iteratee = undefined; @@ -40,6 +39,6 @@ var intersectionBy = baseRest(arrays => { return (mapped.length && mapped[0] === arrays[0]) ? baseIntersection(mapped, baseIteratee(iteratee, 2)) : []; -}); +} export default intersectionBy; diff --git a/intersectionWith.js b/intersectionWith.js index 5ecdede88..a498fec2f 100644 --- a/intersectionWith.js +++ b/intersectionWith.js @@ -1,6 +1,5 @@ import arrayMap from './_arrayMap.js'; import baseIntersection from './_baseIntersection.js'; -import baseRest from './_baseRest.js'; import castArrayLikeObject from './_castArrayLikeObject.js'; import last from './last.js'; @@ -25,9 +24,9 @@ import last from './last.js'; * _.intersectionWith(objects, others, _.isEqual); * // => [{ 'x': 1, 'y': 2 }] */ -var intersectionWith = baseRest(arrays => { - var comparator = last(arrays), - mapped = arrayMap(arrays, castArrayLikeObject); +function intersectionWith(...arrays) { + let comparator = last(arrays); + const mapped = arrayMap(arrays, castArrayLikeObject); comparator = typeof comparator == 'function' ? comparator : undefined; if (comparator) { @@ -36,6 +35,6 @@ var intersectionWith = baseRest(arrays => { return (mapped.length && mapped[0] === arrays[0]) ? baseIntersection(mapped, undefined, comparator) : []; -}); +} export default intersectionWith; diff --git a/invert.js b/invert.js index 1bb07b571..8ba4c3b24 100644 --- a/invert.js +++ b/invert.js @@ -20,7 +20,7 @@ import identity from './identity.js'; * _.invert(object); * // => { '1': 'c', '2': 'b' } */ -var invert = createInverter((result, value, key) => { +const invert = createInverter((result, value, key) => { result[value] = key; }, constant(identity)); diff --git a/invertBy.js b/invertBy.js index b97aabdd9..c9b85259a 100644 --- a/invertBy.js +++ b/invertBy.js @@ -2,10 +2,10 @@ import baseIteratee from './_baseIteratee.js'; import createInverter from './_createInverter.js'; /** Used for built-in method references. */ -var objectProto = Object.prototype; +const objectProto = Object.prototype; /** Used to check objects for own properties. */ -var hasOwnProperty = objectProto.hasOwnProperty; +const hasOwnProperty = objectProto.hasOwnProperty; /** * This method is like `_.invert` except that the inverted object is generated @@ -33,7 +33,7 @@ var hasOwnProperty = objectProto.hasOwnProperty; * }); * // => { 'group1': ['a', 'c'], 'group2': ['b'] } */ -var invertBy = createInverter((result, value, key) => { +const invertBy = createInverter((result, value, key) => { if (hasOwnProperty.call(result, value)) { result[value].push(key); } else { diff --git a/invoke.js b/invoke.js index a21208bd4..645dcaf8c 100644 --- a/invoke.js +++ b/invoke.js @@ -19,6 +19,6 @@ import baseRest from './_baseRest.js'; * _.invoke(object, 'a[0].b.c.slice', 1, 3); * // => [2, 3] */ -var invoke = baseRest(baseInvoke); +const invoke = baseRest(baseInvoke); export default invoke; diff --git a/invokeMap.js b/invokeMap.js index 66d7c0fee..675418c08 100644 --- a/invokeMap.js +++ b/invokeMap.js @@ -1,7 +1,6 @@ import apply from './_apply.js'; import baseEach from './_baseEach.js'; import baseInvoke from './_baseInvoke.js'; -import baseRest from './_baseRest.js'; import isArrayLike from './isArrayLike.js'; /** @@ -27,15 +26,15 @@ import isArrayLike from './isArrayLike.js'; * _.invokeMap([123, 456], String.prototype.split, ''); * // => [['1', '2', '3'], ['4', '5', '6']] */ -var invokeMap = baseRest((collection, path, args) => { - var index = -1, - isFunc = typeof path == 'function', - result = isArrayLike(collection) ? Array(collection.length) : []; +function invokeMap(collection, path, ...args) { + let index = -1; + const isFunc = typeof path == 'function'; + const result = isArrayLike(collection) ? Array(collection.length) : []; baseEach(collection, value => { result[++index] = isFunc ? apply(path, value, args) : baseInvoke(value, path, args); }); return result; -}); +} export default invokeMap; diff --git a/isArguments.js b/isArguments.js index 3a906b3cb..ed2ce23d3 100644 --- a/isArguments.js +++ b/isArguments.js @@ -2,13 +2,13 @@ import baseIsArguments from './_baseIsArguments.js'; import isObjectLike from './isObjectLike.js'; /** Used for built-in method references. */ -var objectProto = Object.prototype; +const objectProto = Object.prototype; /** Used to check objects for own properties. */ -var hasOwnProperty = objectProto.hasOwnProperty; +const hasOwnProperty = objectProto.hasOwnProperty; /** Built-in value references. */ -var propertyIsEnumerable = objectProto.propertyIsEnumerable; +const propertyIsEnumerable = objectProto.propertyIsEnumerable; /** * Checks if `value` is likely an `arguments` object. @@ -28,7 +28,7 @@ var propertyIsEnumerable = objectProto.propertyIsEnumerable; * _.isArguments([1, 2, 3]); * // => false */ -var isArguments = baseIsArguments(function(...args) { return args; }()) ? baseIsArguments : value => isObjectLike(value) && hasOwnProperty.call(value, 'callee') && +const isArguments = baseIsArguments(function(...args) { return args; }()) ? baseIsArguments : value => isObjectLike(value) && hasOwnProperty.call(value, 'callee') && !propertyIsEnumerable.call(value, 'callee'); export default isArguments; diff --git a/isArrayBuffer.js b/isArrayBuffer.js index 32f91ac52..7a9b46772 100644 --- a/isArrayBuffer.js +++ b/isArrayBuffer.js @@ -3,7 +3,7 @@ import baseUnary from './_baseUnary.js'; import nodeUtil from './_nodeUtil.js'; /* Node.js helper references. */ -var nodeIsArrayBuffer = nodeUtil && nodeUtil.isArrayBuffer; +const nodeIsArrayBuffer = nodeUtil && nodeUtil.isArrayBuffer; /** * Checks if `value` is classified as an `ArrayBuffer` object. @@ -22,6 +22,6 @@ var nodeIsArrayBuffer = nodeUtil && nodeUtil.isArrayBuffer; * _.isArrayBuffer(new Array(2)); * // => false */ -var isArrayBuffer = nodeIsArrayBuffer ? baseUnary(nodeIsArrayBuffer) : baseIsArrayBuffer; +const isArrayBuffer = nodeIsArrayBuffer ? baseUnary(nodeIsArrayBuffer) : baseIsArrayBuffer; export default isArrayBuffer; diff --git a/isBoolean.js b/isBoolean.js index 883cee97b..eae258f51 100644 --- a/isBoolean.js +++ b/isBoolean.js @@ -2,7 +2,7 @@ import baseGetTag from './_baseGetTag.js'; import isObjectLike from './isObjectLike.js'; /** `Object#toString` result references. */ -var boolTag = '[object Boolean]'; +const boolTag = '[object Boolean]'; /** * Checks if `value` is classified as a boolean primitive or object. diff --git a/isBuffer.js b/isBuffer.js index d7ba0788d..803e994d5 100644 --- a/isBuffer.js +++ b/isBuffer.js @@ -2,19 +2,19 @@ import root from './_root.js'; import stubFalse from './stubFalse.js'; /** Detect free variable `exports`. */ -var freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports; +const freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports; /** Detect free variable `module`. */ -var freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module; +const freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module; /** Detect the popular CommonJS extension `module.exports`. */ -var moduleExports = freeModule && freeModule.exports === freeExports; +const moduleExports = freeModule && freeModule.exports === freeExports; /** Built-in value references. */ -var Buffer = moduleExports ? root.Buffer : undefined; +const Buffer = moduleExports ? root.Buffer : undefined; /* Built-in method references for those with the same name as other `lodash` methods. */ -var nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined; +const nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined; /** * Checks if `value` is a buffer. @@ -33,6 +33,6 @@ var nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined; * _.isBuffer(new Uint8Array(2)); * // => false */ -var isBuffer = nativeIsBuffer || stubFalse; +const isBuffer = nativeIsBuffer || stubFalse; export default isBuffer; diff --git a/isDate.js b/isDate.js index d586c5125..3fffa3f16 100644 --- a/isDate.js +++ b/isDate.js @@ -3,7 +3,7 @@ import baseUnary from './_baseUnary.js'; import nodeUtil from './_nodeUtil.js'; /* Node.js helper references. */ -var nodeIsDate = nodeUtil && nodeUtil.isDate; +const nodeIsDate = nodeUtil && nodeUtil.isDate; /** * Checks if `value` is classified as a `Date` object. @@ -22,6 +22,6 @@ var nodeIsDate = nodeUtil && nodeUtil.isDate; * _.isDate('Mon April 23 2012'); * // => false */ -var isDate = nodeIsDate ? baseUnary(nodeIsDate) : baseIsDate; +const isDate = nodeIsDate ? baseUnary(nodeIsDate) : baseIsDate; export default isDate; diff --git a/isEmpty.js b/isEmpty.js index c2e55f8ec..496f769c6 100644 --- a/isEmpty.js +++ b/isEmpty.js @@ -8,14 +8,14 @@ import isPrototype from './_isPrototype.js'; import isTypedArray from './isTypedArray.js'; /** `Object#toString` result references. */ -var mapTag = '[object Map]', - setTag = '[object Set]'; +const mapTag = '[object Map]'; +const setTag = '[object Set]'; /** Used for built-in method references. */ -var objectProto = Object.prototype; +const objectProto = Object.prototype; /** Used to check objects for own properties. */ -var hasOwnProperty = objectProto.hasOwnProperty; +const hasOwnProperty = objectProto.hasOwnProperty; /** * Checks if `value` is an empty object, collection, map, or set. @@ -59,14 +59,14 @@ function isEmpty(value) { isBuffer(value) || isTypedArray(value) || isArguments(value))) { return !value.length; } - var tag = getTag(value); + const tag = getTag(value); if (tag == mapTag || tag == setTag) { return !value.size; } if (isPrototype(value)) { return !baseKeys(value).length; } - for (var key in value) { + for (const key in value) { if (hasOwnProperty.call(value, key)) { return false; } diff --git a/isEqualWith.js b/isEqualWith.js index c16f2056a..b92232987 100644 --- a/isEqualWith.js +++ b/isEqualWith.js @@ -34,7 +34,7 @@ import baseIsEqual from './_baseIsEqual.js'; */ function isEqualWith(value, other, customizer) { customizer = typeof customizer == 'function' ? customizer : undefined; - var result = customizer ? customizer(value, other) : undefined; + const result = customizer ? customizer(value, other) : undefined; return result === undefined ? baseIsEqual(value, other, undefined, customizer) : !!result; } diff --git a/isError.js b/isError.js index c57a38bfd..78140891a 100644 --- a/isError.js +++ b/isError.js @@ -3,8 +3,8 @@ import isObjectLike from './isObjectLike.js'; import isPlainObject from './isPlainObject.js'; /** `Object#toString` result references. */ -var domExcTag = '[object DOMException]', - errorTag = '[object Error]'; +const domExcTag = '[object DOMException]'; +const errorTag = '[object Error]'; /** * Checks if `value` is an `Error`, `EvalError`, `RangeError`, `ReferenceError`, @@ -28,7 +28,7 @@ function isError(value) { if (!isObjectLike(value)) { return false; } - var tag = baseGetTag(value); + const tag = baseGetTag(value); return tag == errorTag || tag == domExcTag || (typeof value.message == 'string' && typeof value.name == 'string' && !isPlainObject(value)); } diff --git a/isFinite.js b/isFinite.js index 1c6a50667..16cf17306 100644 --- a/isFinite.js +++ b/isFinite.js @@ -1,7 +1,7 @@ import root from './_root.js'; /* Built-in method references for those with the same name as other `lodash` methods. */ -var nativeIsFinite = root.isFinite; +const nativeIsFinite = root.isFinite; /** * Checks if `value` is a finite primitive number. diff --git a/isFunction.js b/isFunction.js index 57c133d90..aeed5dca3 100644 --- a/isFunction.js +++ b/isFunction.js @@ -2,10 +2,10 @@ import baseGetTag from './_baseGetTag.js'; import isObject from './isObject.js'; /** `Object#toString` result references. */ -var asyncTag = '[object AsyncFunction]', - funcTag = '[object Function]', - genTag = '[object GeneratorFunction]', - proxyTag = '[object Proxy]'; +const asyncTag = '[object AsyncFunction]'; +const funcTag = '[object Function]'; +const genTag = '[object GeneratorFunction]'; +const proxyTag = '[object Proxy]'; /** * Checks if `value` is classified as a `Function` object. @@ -30,7 +30,7 @@ function isFunction(value) { } // The use of `Object#toString` avoids issues with the `typeof` operator // in Safari 9 which returns 'object' for typed arrays and other constructors. - var tag = baseGetTag(value); + const tag = baseGetTag(value); return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag; } diff --git a/isLength.js b/isLength.js index 2acf24e84..3a03a82ac 100644 --- a/isLength.js +++ b/isLength.js @@ -1,5 +1,5 @@ /** Used as references for various `Number` constants. */ -var MAX_SAFE_INTEGER = 9007199254740991; +const MAX_SAFE_INTEGER = 9007199254740991; /** * Checks if `value` is a valid array-like length. diff --git a/isMap.js b/isMap.js index d867dfa85..277bc7bb9 100644 --- a/isMap.js +++ b/isMap.js @@ -3,7 +3,7 @@ import baseUnary from './_baseUnary.js'; import nodeUtil from './_nodeUtil.js'; /* Node.js helper references. */ -var nodeIsMap = nodeUtil && nodeUtil.isMap; +const nodeIsMap = nodeUtil && nodeUtil.isMap; /** * Checks if `value` is classified as a `Map` object. @@ -22,6 +22,6 @@ var nodeIsMap = nodeUtil && nodeUtil.isMap; * _.isMap(new WeakMap); * // => false */ -var isMap = nodeIsMap ? baseUnary(nodeIsMap) : baseIsMap; +const isMap = nodeIsMap ? baseUnary(nodeIsMap) : baseIsMap; export default isMap; diff --git a/isNative.js b/isNative.js index f1d2c327f..d59999e9a 100644 --- a/isNative.js +++ b/isNative.js @@ -2,7 +2,7 @@ import baseIsNative from './_baseIsNative.js'; import isMaskable from './_isMaskable.js'; /** Error message constants. */ -var CORE_ERROR_TEXT = 'Unsupported core-js use. Try https://npms.io/search?q=ponyfill.'; +const CORE_ERROR_TEXT = 'Unsupported core-js use. Try https://npms.io/search?q=ponyfill.'; /** * Checks if `value` is a pristine native function. diff --git a/isNumber.js b/isNumber.js index 8cbdaa6e1..d36a02190 100644 --- a/isNumber.js +++ b/isNumber.js @@ -2,7 +2,7 @@ import baseGetTag from './_baseGetTag.js'; import isObjectLike from './isObjectLike.js'; /** `Object#toString` result references. */ -var numberTag = '[object Number]'; +const numberTag = '[object Number]'; /** * Checks if `value` is classified as a `Number` primitive or object. diff --git a/isObject.js b/isObject.js index ddfebd5bb..e1272f62d 100644 --- a/isObject.js +++ b/isObject.js @@ -24,7 +24,7 @@ * // => false */ function isObject(value) { - var type = typeof value; + const type = typeof value; return value != null && (type == 'object' || type == 'function'); } diff --git a/isPlainObject.js b/isPlainObject.js index 45ec39f2d..90efedb1a 100644 --- a/isPlainObject.js +++ b/isPlainObject.js @@ -3,20 +3,20 @@ import getPrototype from './_getPrototype.js'; import isObjectLike from './isObjectLike.js'; /** `Object#toString` result references. */ -var objectTag = '[object Object]'; +const objectTag = '[object Object]'; /** Used for built-in method references. */ -var funcProto = Function.prototype, - objectProto = Object.prototype; +const funcProto = Function.prototype; +const objectProto = Object.prototype; /** Used to resolve the decompiled source of functions. */ -var funcToString = funcProto.toString; +const funcToString = funcProto.toString; /** Used to check objects for own properties. */ -var hasOwnProperty = objectProto.hasOwnProperty; +const hasOwnProperty = objectProto.hasOwnProperty; /** Used to infer the `Object` constructor. */ -var objectCtorString = funcToString.call(Object); +const objectCtorString = funcToString.call(Object); /** * Checks if `value` is a plain object, that is, an object created by the @@ -50,11 +50,11 @@ function isPlainObject(value) { if (!isObjectLike(value) || baseGetTag(value) != objectTag) { return false; } - var proto = getPrototype(value); + const proto = getPrototype(value); if (proto === null) { return true; } - var Ctor = hasOwnProperty.call(proto, 'constructor') && proto.constructor; + const Ctor = hasOwnProperty.call(proto, 'constructor') && proto.constructor; return typeof Ctor == 'function' && Ctor instanceof Ctor && funcToString.call(Ctor) == objectCtorString; } diff --git a/isRegExp.js b/isRegExp.js index 19580dbba..7282f1e7c 100644 --- a/isRegExp.js +++ b/isRegExp.js @@ -3,7 +3,7 @@ import baseUnary from './_baseUnary.js'; import nodeUtil from './_nodeUtil.js'; /* Node.js helper references. */ -var nodeIsRegExp = nodeUtil && nodeUtil.isRegExp; +const nodeIsRegExp = nodeUtil && nodeUtil.isRegExp; /** * Checks if `value` is classified as a `RegExp` object. @@ -22,6 +22,6 @@ var nodeIsRegExp = nodeUtil && nodeUtil.isRegExp; * _.isRegExp('/abc/'); * // => false */ -var isRegExp = nodeIsRegExp ? baseUnary(nodeIsRegExp) : baseIsRegExp; +const isRegExp = nodeIsRegExp ? baseUnary(nodeIsRegExp) : baseIsRegExp; export default isRegExp; diff --git a/isSafeInteger.js b/isSafeInteger.js index beda91198..92145ba00 100644 --- a/isSafeInteger.js +++ b/isSafeInteger.js @@ -1,7 +1,7 @@ import isInteger from './isInteger.js'; /** Used as references for various `Number` constants. */ -var MAX_SAFE_INTEGER = 9007199254740991; +const MAX_SAFE_INTEGER = 9007199254740991; /** * Checks if `value` is a safe integer. An integer is safe if it's an IEEE-754 diff --git a/isSet.js b/isSet.js index 78c8198ee..56475bd41 100644 --- a/isSet.js +++ b/isSet.js @@ -3,7 +3,7 @@ import baseUnary from './_baseUnary.js'; import nodeUtil from './_nodeUtil.js'; /* Node.js helper references. */ -var nodeIsSet = nodeUtil && nodeUtil.isSet; +const nodeIsSet = nodeUtil && nodeUtil.isSet; /** * Checks if `value` is classified as a `Set` object. @@ -22,6 +22,6 @@ var nodeIsSet = nodeUtil && nodeUtil.isSet; * _.isSet(new WeakSet); * // => false */ -var isSet = nodeIsSet ? baseUnary(nodeIsSet) : baseIsSet; +const isSet = nodeIsSet ? baseUnary(nodeIsSet) : baseIsSet; export default isSet; diff --git a/isString.js b/isString.js index a42295488..1360a5e4f 100644 --- a/isString.js +++ b/isString.js @@ -3,7 +3,7 @@ import isArray from './isArray.js'; import isObjectLike from './isObjectLike.js'; /** `Object#toString` result references. */ -var stringTag = '[object String]'; +const stringTag = '[object String]'; /** * Checks if `value` is classified as a `String` primitive or object. diff --git a/isSymbol.js b/isSymbol.js index 61702c6e6..8cc0b5c2e 100644 --- a/isSymbol.js +++ b/isSymbol.js @@ -2,7 +2,7 @@ import baseGetTag from './_baseGetTag.js'; import isObjectLike from './isObjectLike.js'; /** `Object#toString` result references. */ -var symbolTag = '[object Symbol]'; +const symbolTag = '[object Symbol]'; /** * Checks if `value` is classified as a `Symbol` primitive or object. diff --git a/isTypedArray.js b/isTypedArray.js index 8cffbef95..1dd4830a5 100644 --- a/isTypedArray.js +++ b/isTypedArray.js @@ -3,7 +3,7 @@ import baseUnary from './_baseUnary.js'; import nodeUtil from './_nodeUtil.js'; /* Node.js helper references. */ -var nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray; +const nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray; /** * Checks if `value` is classified as a typed array. @@ -22,6 +22,6 @@ var nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray; * _.isTypedArray([]); * // => false */ -var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray; +const isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray; export default isTypedArray; diff --git a/isWeakMap.js b/isWeakMap.js index a85307f04..d32588a20 100644 --- a/isWeakMap.js +++ b/isWeakMap.js @@ -2,7 +2,7 @@ import getTag from './_getTag.js'; import isObjectLike from './isObjectLike.js'; /** `Object#toString` result references. */ -var weakMapTag = '[object WeakMap]'; +const weakMapTag = '[object WeakMap]'; /** * Checks if `value` is classified as a `WeakMap` object. diff --git a/isWeakSet.js b/isWeakSet.js index 69ad22e53..72930e7bf 100644 --- a/isWeakSet.js +++ b/isWeakSet.js @@ -2,7 +2,7 @@ import baseGetTag from './_baseGetTag.js'; import isObjectLike from './isObjectLike.js'; /** `Object#toString` result references. */ -var weakSetTag = '[object WeakSet]'; +const weakSetTag = '[object WeakSet]'; /** * Checks if `value` is classified as a `WeakSet` object. diff --git a/join.js b/join.js index 61dd65b2a..e4633bbed 100644 --- a/join.js +++ b/join.js @@ -1,8 +1,8 @@ /** Used for built-in method references. */ -var arrayProto = Array.prototype; +const arrayProto = Array.prototype; /* Built-in method references for those with the same name as other `lodash` methods. */ -var nativeJoin = arrayProto.join; +const nativeJoin = arrayProto.join; /** * Converts all elements in `array` into a string separated by `separator`. diff --git a/kebabCase.js b/kebabCase.js index 2921e0c63..463cb2066 100644 --- a/kebabCase.js +++ b/kebabCase.js @@ -21,6 +21,6 @@ import createCompounder from './_createCompounder.js'; * _.kebabCase('__FOO_BAR__'); * // => 'foo-bar' */ -var kebabCase = createCompounder((result, word, index) => result + (index ? '-' : '') + word.toLowerCase()); +const kebabCase = createCompounder((result, word, index) => result + (index ? '-' : '') + word.toLowerCase()); export default kebabCase; diff --git a/keyBy.js b/keyBy.js index e7982b882..13b34e79b 100644 --- a/keyBy.js +++ b/keyBy.js @@ -29,7 +29,7 @@ import createAggregator from './_createAggregator.js'; * _.keyBy(array, 'dir'); * // => { 'left': { 'dir': 'left', 'code': 97 }, 'right': { 'dir': 'right', 'code': 100 } } */ -var keyBy = createAggregator((result, value, key) => { +const keyBy = createAggregator((result, value, key) => { baseAssignValue(result, key, value); }); diff --git a/last.js b/last.js index b4135f703..bd3931ba0 100644 --- a/last.js +++ b/last.js @@ -13,7 +13,7 @@ * // => 3 */ function last(array) { - var length = array == null ? 0 : array.length; + const length = array == null ? 0 : array.length; return length ? array[length - 1] : undefined; } diff --git a/lastIndexOf.js b/lastIndexOf.js index bf6eac8c4..dece6729a 100644 --- a/lastIndexOf.js +++ b/lastIndexOf.js @@ -4,8 +4,8 @@ import strictLastIndexOf from './_strictLastIndexOf.js'; import toInteger from './toInteger.js'; /* Built-in method references for those with the same name as other `lodash` methods. */ -var nativeMax = Math.max, - nativeMin = Math.min; +const nativeMax = Math.max; +const nativeMin = Math.min; /** * This method is like `_.indexOf` except that it iterates over elements of @@ -29,11 +29,11 @@ var nativeMax = Math.max, * // => 1 */ function lastIndexOf(array, value, fromIndex) { - var length = array == null ? 0 : array.length; + const length = array == null ? 0 : array.length; if (!length) { return -1; } - var index = length; + let index = length; if (fromIndex !== undefined) { index = toInteger(fromIndex); index = index < 0 ? nativeMax(length + index, 0) : nativeMin(index, length - 1); diff --git a/lowerCase.js b/lowerCase.js index 46286b253..240c0825c 100644 --- a/lowerCase.js +++ b/lowerCase.js @@ -20,6 +20,6 @@ import createCompounder from './_createCompounder.js'; * _.lowerCase('__FOO_BAR__'); * // => 'foo bar' */ -var lowerCase = createCompounder((result, word, index) => result + (index ? ' ' : '') + word.toLowerCase()); +const lowerCase = createCompounder((result, word, index) => result + (index ? ' ' : '') + word.toLowerCase()); export default lowerCase; diff --git a/lowerFirst.js b/lowerFirst.js index d7cb4b013..47ba4204f 100644 --- a/lowerFirst.js +++ b/lowerFirst.js @@ -17,6 +17,6 @@ import createCaseFirst from './_createCaseFirst.js'; * _.lowerFirst('FRED'); * // => 'fRED' */ -var lowerFirst = createCaseFirst('toLowerCase'); +const lowerFirst = createCaseFirst('toLowerCase'); export default lowerFirst; diff --git a/lt.js b/lt.js index 84181139c..e9504a201 100644 --- a/lt.js +++ b/lt.js @@ -24,6 +24,6 @@ import createRelationalOperation from './_createRelationalOperation.js'; * _.lt(3, 1); * // => false */ -var lt = createRelationalOperation(baseLt); +const lt = createRelationalOperation(baseLt); export default lt; diff --git a/lte.js b/lte.js index bd8bcd8c7..5da4d37bc 100644 --- a/lte.js +++ b/lte.js @@ -23,6 +23,6 @@ import createRelationalOperation from './_createRelationalOperation.js'; * _.lte(3, 1); * // => false */ -var lte = createRelationalOperation((value, other) => value <= other); +const lte = createRelationalOperation((value, other) => value <= other); export default lte; diff --git a/map.js b/map.js index 36139f96b..975fea381 100644 --- a/map.js +++ b/map.js @@ -46,7 +46,7 @@ import isArray from './isArray.js'; * // => ['barney', 'fred'] */ function map(collection, iteratee) { - var func = isArray(collection) ? arrayMap : baseMap; + const func = isArray(collection) ? arrayMap : baseMap; return func(collection, baseIteratee(iteratee, 3)); } diff --git a/mapKeys.js b/mapKeys.js index 7b4b5b071..0d8969a7a 100644 --- a/mapKeys.js +++ b/mapKeys.js @@ -24,7 +24,7 @@ import baseIteratee from './_baseIteratee.js'; * // => { 'a1': 1, 'b2': 2 } */ function mapKeys(object, iteratee) { - var result = {}; + const result = {}; iteratee = baseIteratee(iteratee, 3); baseForOwn(object, (value, key, object) => { diff --git a/mapValues.js b/mapValues.js index c50f33caf..513db9de5 100644 --- a/mapValues.js +++ b/mapValues.js @@ -31,7 +31,7 @@ import baseIteratee from './_baseIteratee.js'; * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed) */ function mapValues(object, iteratee) { - var result = {}; + const result = {}; iteratee = baseIteratee(iteratee, 3); baseForOwn(object, (value, key, object) => { diff --git a/matches.js b/matches.js index 62aed6c77..d99201086 100644 --- a/matches.js +++ b/matches.js @@ -2,7 +2,7 @@ import baseClone from './_baseClone.js'; import baseMatches from './_baseMatches.js'; /** Used to compose bitmasks for cloning. */ -var CLONE_DEEP_FLAG = 1; +const CLONE_DEEP_FLAG = 1; /** * Creates a function that performs a partial deep comparison between a given diff --git a/matchesProperty.js b/matchesProperty.js index a98fea92c..4ec6d7942 100644 --- a/matchesProperty.js +++ b/matchesProperty.js @@ -2,7 +2,7 @@ import baseClone from './_baseClone.js'; import baseMatchesProperty from './_baseMatchesProperty.js'; /** Used to compose bitmasks for cloning. */ -var CLONE_DEEP_FLAG = 1; +const CLONE_DEEP_FLAG = 1; /** * Creates a function that performs a partial deep comparison between the diff --git a/memoize.js b/memoize.js index 41a1615ab..24157538f 100644 --- a/memoize.js +++ b/memoize.js @@ -1,7 +1,7 @@ import MapCache from './_MapCache.js'; /** Error message constants. */ -var FUNC_ERROR_TEXT = 'Expected a function'; +const FUNC_ERROR_TEXT = 'Expected a function'; /** * Creates a function that memoizes the result of `func`. If `resolver` is @@ -51,15 +51,14 @@ function memoize(func, resolver) { if (typeof func != 'function' || (resolver != null && typeof resolver != 'function')) { throw new TypeError(FUNC_ERROR_TEXT); } - var memoized = function() { - var args = arguments, - key = resolver ? resolver.apply(this, args) : args[0], - cache = memoized.cache; + const memoized = function() { + const args = arguments, key = resolver ? resolver.apply(this, args) : args[0]; + const cache = memoized.cache; if (cache.has(key)) { return cache.get(key); } - var result = func.apply(this, args); + const result = func.apply(this, args); memoized.cache = cache.set(key, result) || cache; return result; }; diff --git a/merge.js b/merge.js index 3c74c7899..165f43f6c 100644 --- a/merge.js +++ b/merge.js @@ -32,7 +32,7 @@ import createAssigner from './_createAssigner.js'; * _.merge(object, other); * // => { 'a': [{ 'b': 2, 'c': 3 }, { 'd': 4, 'e': 5 }] } */ -var merge = createAssigner((object, source, srcIndex) => { +const merge = createAssigner((object, source, srcIndex) => { baseMerge(object, source, srcIndex); }); diff --git a/mergeWith.js b/mergeWith.js index e78913d27..3a1be0ff7 100644 --- a/mergeWith.js +++ b/mergeWith.js @@ -32,7 +32,7 @@ import createAssigner from './_createAssigner.js'; * _.mergeWith(object, other, customizer); * // => { 'a': [1, 3], 'b': [2, 4] } */ -var mergeWith = createAssigner((object, source, srcIndex, customizer) => { +const mergeWith = createAssigner((object, source, srcIndex, customizer) => { baseMerge(object, source, srcIndex, customizer); }); diff --git a/method.js b/method.js index 7b795d89b..2ac632845 100644 --- a/method.js +++ b/method.js @@ -25,6 +25,6 @@ import baseRest from './_baseRest.js'; * _.map(objects, _.method(['a', 'b'])); * // => [2, 1] */ -var method = baseRest((path, args) => object => baseInvoke(object, path, args)); +const method = baseRest((path, args) => object => baseInvoke(object, path, args)); export default method; diff --git a/methodOf.js b/methodOf.js index dfd3d38b7..c37781eed 100644 --- a/methodOf.js +++ b/methodOf.js @@ -24,6 +24,6 @@ import baseRest from './_baseRest.js'; * _.map([['a', '2'], ['c', '0']], _.methodOf(object)); * // => [2, 0] */ -var methodOf = baseRest((object, args) => path => baseInvoke(object, path, args)); +const methodOf = baseRest((object, args) => path => baseInvoke(object, path, args)); export default methodOf; diff --git a/multiply.js b/multiply.js index 0584093f2..0831be953 100644 --- a/multiply.js +++ b/multiply.js @@ -15,6 +15,6 @@ import createMathOperation from './_createMathOperation.js'; * _.multiply(6, 4); * // => 24 */ -var multiply = createMathOperation((multiplier, multiplicand) => multiplier * multiplicand, 1); +const multiply = createMathOperation((multiplier, multiplicand) => multiplier * multiplicand, 1); export default multiply; diff --git a/negate.js b/negate.js index 9c23aa8ae..16eb8fa6e 100644 --- a/negate.js +++ b/negate.js @@ -1,5 +1,5 @@ /** Error message constants. */ -var FUNC_ERROR_TEXT = 'Expected a function'; +const FUNC_ERROR_TEXT = 'Expected a function'; /** * Creates a function that negates the result of the predicate `func`. The @@ -26,7 +26,7 @@ function negate(predicate) { throw new TypeError(FUNC_ERROR_TEXT); } return function() { - var args = arguments; + const args = arguments; switch (args.length) { case 0: return !predicate.call(this); case 1: return !predicate.call(this, args[0]); diff --git a/now.js b/now.js index f31771cc1..3167edc80 100644 --- a/now.js +++ b/now.js @@ -16,6 +16,6 @@ import root from './_root.js'; * }, _.now()); * // => Logs the number of milliseconds it took for the deferred invocation. */ -var now = () => root.Date.now(); +const now = () => root.Date.now(); export default now; diff --git a/over.js b/over.js index 51b6339d1..5313b2622 100644 --- a/over.js +++ b/over.js @@ -19,6 +19,6 @@ import createOver from './_createOver.js'; * func(1, 2, 3, 4); * // => [4, 1] */ -var over = createOver(arrayMap); +const over = createOver(arrayMap); export default over; diff --git a/overArgs.js b/overArgs.js index a4856cec0..7e7bc5243 100644 --- a/overArgs.js +++ b/overArgs.js @@ -2,13 +2,11 @@ import apply from './_apply.js'; import arrayMap from './_arrayMap.js'; import baseFlatten from './_baseFlatten.js'; import baseIteratee from './_baseIteratee.js'; -import baseRest from './_baseRest.js'; import baseUnary from './_baseUnary.js'; -import castRest from './_castRest.js'; import isArray from './isArray.js'; /* Built-in method references for those with the same name as other `lodash` methods. */ -var nativeMin = Math.min; +const nativeMin = Math.min; /** * Creates a function that invokes `func` with its arguments transformed. @@ -41,21 +39,21 @@ var nativeMin = Math.min; * func(10, 5); * // => [100, 10] */ -var overArgs = castRest((func, transforms) => { +function overArgs(func, ...transforms) { transforms = (transforms.length == 1 && isArray(transforms[0])) ? arrayMap(transforms[0], baseUnary(baseIteratee)) : arrayMap(baseFlatten(transforms, 1), baseUnary(baseIteratee)); - var funcsLength = transforms.length; - return baseRest(function(args) { - var index = -1, - length = nativeMin(args.length, funcsLength); + const funcsLength = transforms.length; + return function(...args) { + let index = -1; + const length = nativeMin(args.length, funcsLength); while (++index < length) { args[index] = transforms[index].call(this, args[index]); } return apply(func, this, args); - }); -}); + }; +} export default overArgs; diff --git a/overEvery.js b/overEvery.js index 6b262d8b3..448dd9b90 100644 --- a/overEvery.js +++ b/overEvery.js @@ -25,6 +25,6 @@ import createOver from './_createOver.js'; * func(NaN); * // => false */ -var overEvery = createOver(arrayEvery); +const overEvery = createOver(arrayEvery); export default overEvery; diff --git a/overSome.js b/overSome.js index 9893ba670..f5fff5780 100644 --- a/overSome.js +++ b/overSome.js @@ -25,6 +25,6 @@ import createOver from './_createOver.js'; * func(NaN); * // => false */ -var overSome = createOver(arraySome); +const overSome = createOver(arraySome); export default overSome; diff --git a/pad.js b/pad.js index b74a0972f..663a0ddf8 100644 --- a/pad.js +++ b/pad.js @@ -4,8 +4,8 @@ import toInteger from './toInteger.js'; import toString from './toString.js'; /* Built-in method references for those with the same name as other `lodash` methods. */ -var nativeCeil = Math.ceil, - nativeFloor = Math.floor; +const nativeCeil = Math.ceil; +const nativeFloor = Math.floor; /** * Pads `string` on the left and right sides if it's shorter than `length`. @@ -34,11 +34,11 @@ function pad(string, length, chars) { string = toString(string); length = toInteger(length); - var strLength = length ? stringSize(string) : 0; + const strLength = length ? stringSize(string) : 0; if (!length || strLength >= length) { return string; } - var mid = (length - strLength) / 2; + const mid = (length - strLength) / 2; return ( createPadding(nativeFloor(mid), chars) + string + diff --git a/padEnd.js b/padEnd.js index c7df21b8a..79db66097 100644 --- a/padEnd.js +++ b/padEnd.js @@ -30,7 +30,7 @@ function padEnd(string, length, chars) { string = toString(string); length = toInteger(length); - var strLength = length ? stringSize(string) : 0; + const strLength = length ? stringSize(string) : 0; return (length && strLength < length) ? (string + createPadding(length - strLength, chars)) : string; diff --git a/padStart.js b/padStart.js index c61644acf..072fc4d0f 100644 --- a/padStart.js +++ b/padStart.js @@ -30,7 +30,7 @@ function padStart(string, length, chars) { string = toString(string); length = toInteger(length); - var strLength = length ? stringSize(string) : 0; + const strLength = length ? stringSize(string) : 0; return (length && strLength < length) ? (createPadding(length - strLength, chars) + string) : string; diff --git a/parseInt.js b/parseInt.js index 3400b6b9e..d27ce1862 100644 --- a/parseInt.js +++ b/parseInt.js @@ -2,10 +2,10 @@ import root from './_root.js'; import toString from './toString.js'; /** Used to match leading and trailing whitespace. */ -var reTrimStart = /^\s+/; +const reTrimStart = /^\s+/; /* Built-in method references for those with the same name as other `lodash` methods. */ -var nativeParseInt = root.parseInt; +const nativeParseInt = root.parseInt; /** * Converts `string` to an integer of the specified radix. If `radix` is diff --git a/pick.js b/pick.js index d7ded1a9f..eb922624f 100644 --- a/pick.js +++ b/pick.js @@ -18,6 +18,6 @@ import flatRest from './_flatRest.js'; * _.pick(object, ['a', 'c']); * // => { 'a': 1, 'c': 3 } */ -var pick = flatRest((object, paths) => object == null ? {} : basePick(object, paths)); +const pick = flatRest((object, paths) => object == null ? {} : basePick(object, paths)); export default pick; diff --git a/pickBy.js b/pickBy.js index 9041152ca..3e8680c05 100644 --- a/pickBy.js +++ b/pickBy.js @@ -25,7 +25,7 @@ function pickBy(object, predicate) { if (object == null) { return {}; } - var props = arrayMap(getAllKeysIn(object), prop => [prop]); + const props = arrayMap(getAllKeysIn(object), prop => [prop]); predicate = baseIteratee(predicate); return basePickBy(object, props, (value, path) => predicate(value, path[0])); } diff --git a/pull.js b/pull.js index 10872f254..b125a0ea4 100644 --- a/pull.js +++ b/pull.js @@ -24,6 +24,6 @@ import pullAll from './pullAll.js'; * console.log(array); * // => ['b', 'b'] */ -var pull = baseRest(pullAll); +const pull = baseRest(pullAll); export default pull; diff --git a/pullAt.js b/pullAt.js index 71806d9ee..d7c4e5905 100644 --- a/pullAt.js +++ b/pullAt.js @@ -29,9 +29,8 @@ import isIndex from './_isIndex.js'; * console.log(pulled); * // => ['b', 'd'] */ -var pullAt = flatRest((array, indexes) => { - var length = array == null ? 0 : array.length, - result = baseAt(array, indexes); +const pullAt = flatRest((array, indexes) => { + const length = array == null ? 0 : array.length, result = baseAt(array, indexes); basePullAt(array, arrayMap(indexes, index => isIndex(index, length) ? +index : index).sort(compareAscending)); diff --git a/random.js b/random.js index b97563dbc..c332b9e37 100644 --- a/random.js +++ b/random.js @@ -3,11 +3,11 @@ import isIterateeCall from './_isIterateeCall.js'; import toFinite from './toFinite.js'; /** Built-in method references without a dependency on `root`. */ -var freeParseFloat = parseFloat; +const freeParseFloat = parseFloat; /* Built-in method references for those with the same name as other `lodash` methods. */ -var nativeMin = Math.min, - nativeRandom = Math.random; +const nativeMin = Math.min; +const nativeRandom = Math.random; /** * Produces a random number between the inclusive `lower` and `upper` bounds. @@ -68,12 +68,12 @@ function random(lower, upper, floating) { } } if (lower > upper) { - var temp = lower; + const temp = lower; lower = upper; upper = temp; } if (floating || lower % 1 || upper % 1) { - var rand = nativeRandom(); + const rand = nativeRandom(); return nativeMin(lower + (rand * (upper - lower + freeParseFloat('1e-' + ((rand + '').length - 1)))), upper); } return baseRandom(lower, upper); diff --git a/range.js b/range.js index 71f26da82..cacdd108c 100644 --- a/range.js +++ b/range.js @@ -41,6 +41,6 @@ import createRange from './_createRange.js'; * _.range(0); * // => [] */ -var range = createRange(); +const range = createRange(); export default range; diff --git a/rangeRight.js b/rangeRight.js index 3472513d5..5fac26e9e 100644 --- a/rangeRight.js +++ b/rangeRight.js @@ -36,6 +36,6 @@ import createRange from './_createRange.js'; * _.rangeRight(0); * // => [] */ -var rangeRight = createRange(true); +const rangeRight = createRange(true); export default rangeRight; diff --git a/rearg.js b/rearg.js index bc0c9be83..91984dd7f 100644 --- a/rearg.js +++ b/rearg.js @@ -2,7 +2,7 @@ import createWrap from './_createWrap.js'; import flatRest from './_flatRest.js'; /** Used to compose bitmasks for function metadata. */ -var WRAP_REARG_FLAG = 256; +const WRAP_REARG_FLAG = 256; /** * Creates a function that invokes `func` with arguments arranged according @@ -26,6 +26,6 @@ var WRAP_REARG_FLAG = 256; * rearged('b', 'c', 'a') * // => ['a', 'b', 'c'] */ -var rearg = flatRest((func, indexes) => createWrap(func, WRAP_REARG_FLAG, undefined, undefined, undefined, indexes)); +const rearg = flatRest((func, indexes) => createWrap(func, WRAP_REARG_FLAG, undefined, undefined, undefined, indexes)); export default rearg; diff --git a/reduce.js b/reduce.js index 5dc6c1223..64e6da631 100644 --- a/reduce.js +++ b/reduce.js @@ -42,8 +42,8 @@ import isArray from './isArray.js'; * // => { '1': ['a', 'c'], '2': ['b'] } (iteration order is not guaranteed) */ function reduce(collection, iteratee, accumulator) { - var func = isArray(collection) ? arrayReduce : baseReduce, - initAccum = arguments.length < 3; + const func = isArray(collection) ? arrayReduce : baseReduce; + const initAccum = arguments.length < 3; return func(collection, baseIteratee(iteratee, 4), accumulator, initAccum, baseEach); } diff --git a/reduceRight.js b/reduceRight.js index b0f5d82df..954c7bdc9 100644 --- a/reduceRight.js +++ b/reduceRight.js @@ -27,8 +27,8 @@ import isArray from './isArray.js'; * // => [4, 5, 2, 3, 0, 1] */ function reduceRight(collection, iteratee, accumulator) { - var func = isArray(collection) ? arrayReduceRight : baseReduce, - initAccum = arguments.length < 3; + const func = isArray(collection) ? arrayReduceRight : baseReduce; + const initAccum = arguments.length < 3; return func(collection, baseIteratee(iteratee, 4), accumulator, initAccum, baseEachRight); } diff --git a/remove.js b/remove.js index c1e775f10..f705cbe7e 100644 --- a/remove.js +++ b/remove.js @@ -30,17 +30,17 @@ import basePullAt from './_basePullAt.js'; * // => [2, 4] */ function remove(array, predicate) { - var result = []; + const result = []; if (!(array && array.length)) { return result; } - var index = -1, - indexes = [], - length = array.length; + let index = -1; + const indexes = []; + const length = array.length; predicate = baseIteratee(predicate, 3); while (++index < length) { - var value = array[index]; + const value = array[index]; if (predicate(value, index, array)) { result.push(value); indexes.push(index); diff --git a/replace.js b/replace.js index c14a16985..9a714e0f5 100644 --- a/replace.js +++ b/replace.js @@ -20,8 +20,8 @@ import toString from './toString.js'; * // => 'Hi Barney' */ function replace() { - var args = arguments, - string = toString(args[0]); + const args = arguments; + const string = toString(args[0]); return args.length < 3 ? string : string.replace(args[1], args[2]); }