From f2c49500ee286675718c1bddcbb85d932fcd4652 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Mon, 9 Jan 2017 18:16:47 -0800 Subject: [PATCH] Consolidate prototype vars used only once. --- _arrayLikeKeys.js | 5 +---- _assignValue.js | 5 +---- _baseHas.js | 5 +---- _baseIsEqualDeep.js | 5 +---- _baseKeys.js | 5 +---- _baseKeysIn.js | 5 +---- _basePullAll.js | 5 +---- _basePullAt.js | 5 +---- _equalObjects.js | 5 +---- _getFuncName.js | 5 +---- _getSymbols.js | 5 +---- _hashGet.js | 5 +---- _hashHas.js | 5 +---- _initCloneArray.js | 5 +---- _listCacheDelete.js | 5 +---- _objectToString.js | 5 +---- _toSource.js | 5 +---- countBy.js | 5 +---- groupBy.js | 5 +---- invertBy.js | 5 +---- isEmpty.js | 5 +---- isNative.js | 8 ++------ isPlainObject.js | 8 ++------ join.js | 5 +---- reverse.js | 5 +---- 25 files changed, 27 insertions(+), 104 deletions(-) diff --git a/_arrayLikeKeys.js b/_arrayLikeKeys.js index 8e214e84b..6dedf128b 100644 --- a/_arrayLikeKeys.js +++ b/_arrayLikeKeys.js @@ -5,11 +5,8 @@ import isBuffer from './isBuffer.js'; import isIndex from './_isIndex.js'; import isTypedArray from './isTypedArray.js'; -/** Used for built-in method references. */ -const objectProto = Object.prototype; - /** Used to check objects for own properties. */ -const hasOwnProperty = objectProto.hasOwnProperty; +const hasOwnProperty = Object.prototype.hasOwnProperty; /** * Creates an array of the enumerable property names of the array-like `value`. diff --git a/_assignValue.js b/_assignValue.js index 8ec98a086..75e4f8eff 100644 --- a/_assignValue.js +++ b/_assignValue.js @@ -1,11 +1,8 @@ import baseAssignValue from './_baseAssignValue.js'; import eq from './eq.js'; -/** Used for built-in method references. */ -const objectProto = Object.prototype; - /** Used to check objects for own properties. */ -const hasOwnProperty = objectProto.hasOwnProperty; +const hasOwnProperty = Object.prototype.hasOwnProperty; /** * Assigns `value` to `key` of `object` if the existing value is not equivalent diff --git a/_baseHas.js b/_baseHas.js index 2b7e091b0..e47fd26fb 100644 --- a/_baseHas.js +++ b/_baseHas.js @@ -1,8 +1,5 @@ -/** Used for built-in method references. */ -const objectProto = Object.prototype; - /** Used to check objects for own properties. */ -const hasOwnProperty = objectProto.hasOwnProperty; +const hasOwnProperty = Object.prototype.hasOwnProperty; /** * The base implementation of `has` without support for deep paths. diff --git a/_baseIsEqualDeep.js b/_baseIsEqualDeep.js index c18686b88..31814c79c 100644 --- a/_baseIsEqualDeep.js +++ b/_baseIsEqualDeep.js @@ -15,11 +15,8 @@ const argsTag = '[object Arguments]'; const arrayTag = '[object Array]'; const objectTag = '[object Object]'; -/** Used for built-in method references. */ -const objectProto = Object.prototype; - /** Used to check objects for own properties. */ -const hasOwnProperty = objectProto.hasOwnProperty; +const hasOwnProperty = Object.prototype.hasOwnProperty; /** * A specialized version of `baseIsEqual` for arrays and objects which performs diff --git a/_baseKeys.js b/_baseKeys.js index a9ff23034..51c64fcc8 100644 --- a/_baseKeys.js +++ b/_baseKeys.js @@ -1,11 +1,8 @@ import isPrototype from './_isPrototype.js'; import nativeKeys from './_nativeKeys.js'; -/** Used for built-in method references. */ -const objectProto = Object.prototype; - /** Used to check objects for own properties. */ -const hasOwnProperty = objectProto.hasOwnProperty; +const hasOwnProperty = Object.prototype.hasOwnProperty; /** * The base implementation of `keys` which doesn't treat sparse arrays as dense. diff --git a/_baseKeysIn.js b/_baseKeysIn.js index 8ede5b552..62bbad78e 100644 --- a/_baseKeysIn.js +++ b/_baseKeysIn.js @@ -2,11 +2,8 @@ import isObject from './isObject.js'; import isPrototype from './_isPrototype.js'; import nativeKeysIn from './_nativeKeysIn.js'; -/** Used for built-in method references. */ -const objectProto = Object.prototype; - /** Used to check objects for own properties. */ -const hasOwnProperty = objectProto.hasOwnProperty; +const hasOwnProperty = Object.prototype.hasOwnProperty; /** * The base implementation of `keysIn` which doesn't treat sparse arrays as dense. diff --git a/_basePullAll.js b/_basePullAll.js index f8dd5a881..59eceff73 100644 --- a/_basePullAll.js +++ b/_basePullAll.js @@ -3,11 +3,8 @@ import baseIndexOf from './_baseIndexOf.js'; import baseIndexOfWith from './_baseIndexOfWith.js'; import copyArray from './_copyArray.js'; -/** Used for built-in method references. */ -const arrayProto = Array.prototype; - /** Built-in value references. */ -const splice = arrayProto.splice; +const splice = Array.prototype.splice; /** * The base implementation of `pullAllBy`. diff --git a/_basePullAt.js b/_basePullAt.js index 70b4cf86d..45a6a5dd3 100644 --- a/_basePullAt.js +++ b/_basePullAt.js @@ -1,11 +1,8 @@ import baseUnset from './_baseUnset.js'; import isIndex from './_isIndex.js'; -/** Used for built-in method references. */ -const arrayProto = Array.prototype; - /** Built-in value references. */ -const splice = arrayProto.splice; +const splice = Array.prototype.splice; /** * The base implementation of `pullAt` without support for individual diff --git a/_equalObjects.js b/_equalObjects.js index 3949864ae..d4608fe60 100644 --- a/_equalObjects.js +++ b/_equalObjects.js @@ -3,11 +3,8 @@ import getAllKeys from './_getAllKeys.js'; /** Used to compose bitmasks for value comparisons. */ const COMPARE_PARTIAL_FLAG = 1; -/** Used for built-in method references. */ -const objectProto = Object.prototype; - /** Used to check objects for own properties. */ -const hasOwnProperty = objectProto.hasOwnProperty; +const hasOwnProperty = Object.prototype.hasOwnProperty; /** * A specialized version of `baseIsEqualDeep` for objects with support for diff --git a/_getFuncName.js b/_getFuncName.js index 1a3ffc140..653ff04d3 100644 --- a/_getFuncName.js +++ b/_getFuncName.js @@ -1,10 +1,7 @@ import realNames from './_realNames.js'; -/** Used for built-in method references. */ -const objectProto = Object.prototype; - /** Used to check objects for own properties. */ -const hasOwnProperty = objectProto.hasOwnProperty; +const hasOwnProperty = Object.prototype.hasOwnProperty; /** * Gets the name of `func`. diff --git a/_getSymbols.js b/_getSymbols.js index 72687d3f6..cc425069e 100644 --- a/_getSymbols.js +++ b/_getSymbols.js @@ -1,11 +1,8 @@ import arrayFilter from './_arrayFilter.js'; import stubArray from './stubArray.js'; -/** Used for built-in method references. */ -const objectProto = Object.prototype; - /** Built-in value references. */ -const propertyIsEnumerable = objectProto.propertyIsEnumerable; +const propertyIsEnumerable = Object.prototype.propertyIsEnumerable; /* Built-in method references for those with the same name as other `lodash` methods. */ const nativeGetSymbols = Object.getOwnPropertySymbols; diff --git a/_hashGet.js b/_hashGet.js index 14718d052..adeba2853 100644 --- a/_hashGet.js +++ b/_hashGet.js @@ -3,11 +3,8 @@ import nativeCreate from './_nativeCreate.js'; /** Used to stand-in for `undefined` hash values. */ const HASH_UNDEFINED = '__lodash_hash_undefined__'; -/** Used for built-in method references. */ -const objectProto = Object.prototype; - /** Used to check objects for own properties. */ -const hasOwnProperty = objectProto.hasOwnProperty; +const hasOwnProperty = Object.prototype.hasOwnProperty; /** * Gets the hash value for `key`. diff --git a/_hashHas.js b/_hashHas.js index ba9c40703..78c731a37 100644 --- a/_hashHas.js +++ b/_hashHas.js @@ -1,10 +1,7 @@ import nativeCreate from './_nativeCreate.js'; -/** Used for built-in method references. */ -const objectProto = Object.prototype; - /** Used to check objects for own properties. */ -const hasOwnProperty = objectProto.hasOwnProperty; +const hasOwnProperty = Object.prototype.hasOwnProperty; /** * Checks if a hash value for `key` exists. diff --git a/_initCloneArray.js b/_initCloneArray.js index 138658151..25d89fd9c 100644 --- a/_initCloneArray.js +++ b/_initCloneArray.js @@ -1,8 +1,5 @@ -/** Used for built-in method references. */ -const objectProto = Object.prototype; - /** Used to check objects for own properties. */ -const hasOwnProperty = objectProto.hasOwnProperty; +const hasOwnProperty = Object.prototype.hasOwnProperty; /** * Initializes an array clone. diff --git a/_listCacheDelete.js b/_listCacheDelete.js index 00162bd92..26a8a8edd 100644 --- a/_listCacheDelete.js +++ b/_listCacheDelete.js @@ -1,10 +1,7 @@ import assocIndexOf from './_assocIndexOf.js'; -/** Used for built-in method references. */ -const arrayProto = Array.prototype; - /** Built-in value references. */ -const splice = arrayProto.splice; +const splice = Array.prototype.splice; /** * Removes `key` and its value from the list cache. diff --git a/_objectToString.js b/_objectToString.js index a3e4dbd26..4a22e3ead 100644 --- a/_objectToString.js +++ b/_objectToString.js @@ -1,12 +1,9 @@ -/** Used for built-in method references. */ -const objectProto = Object.prototype; - /** * Used to resolve the * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring) * of values. */ -const nativeObjectToString = objectProto.toString; +const nativeObjectToString = Object.prototype.toString; /** * Converts `value` to a string using `Object.prototype.toString`. diff --git a/_toSource.js b/_toSource.js index 9da9b29c8..b057ac620 100644 --- a/_toSource.js +++ b/_toSource.js @@ -1,8 +1,5 @@ -/** Used for built-in method references. */ -const funcProto = Function.prototype; - /** Used to resolve the decompiled source of functions. */ -const funcToString = funcProto.toString; +const funcToString = Function.prototype.toString; /** * Converts `func` to its source code. diff --git a/countBy.js b/countBy.js index d308cd153..1f4e222a9 100644 --- a/countBy.js +++ b/countBy.js @@ -1,11 +1,8 @@ import baseAssignValue from './_baseAssignValue.js'; import createAggregator from './_createAggregator.js'; -/** Used for built-in method references. */ -const objectProto = Object.prototype; - /** Used to check objects for own properties. */ -const hasOwnProperty = objectProto.hasOwnProperty; +const hasOwnProperty = Object.prototype.hasOwnProperty; /** * Creates an object composed of keys generated from the results of running diff --git a/groupBy.js b/groupBy.js index a4c8ff97c..25384dd38 100644 --- a/groupBy.js +++ b/groupBy.js @@ -1,11 +1,8 @@ import baseAssignValue from './_baseAssignValue.js'; import createAggregator from './_createAggregator.js'; -/** Used for built-in method references. */ -const objectProto = Object.prototype; - /** Used to check objects for own properties. */ -const hasOwnProperty = objectProto.hasOwnProperty; +const hasOwnProperty = Object.prototype.hasOwnProperty; /** * Creates an object composed of keys generated from the results of running diff --git a/invertBy.js b/invertBy.js index ac3ef7a2b..5e9c4f6be 100644 --- a/invertBy.js +++ b/invertBy.js @@ -1,10 +1,7 @@ import createInverter from './_createInverter.js'; -/** Used for built-in method references. */ -const objectProto = Object.prototype; - /** Used to check objects for own properties. */ -const hasOwnProperty = objectProto.hasOwnProperty; +const hasOwnProperty = Object.prototype.hasOwnProperty; /** * This method is like `invert` except that the inverted object is generated diff --git a/isEmpty.js b/isEmpty.js index cd7446fbe..e80574f63 100644 --- a/isEmpty.js +++ b/isEmpty.js @@ -11,11 +11,8 @@ import isTypedArray from './isTypedArray.js'; const mapTag = '[object Map]'; const setTag = '[object Set]'; -/** Used for built-in method references. */ -const objectProto = Object.prototype; - /** Used to check objects for own properties. */ -const hasOwnProperty = objectProto.hasOwnProperty; +const hasOwnProperty = Object.prototype.hasOwnProperty; /** * Checks if `value` is an empty object, collection, map, or set. diff --git a/isNative.js b/isNative.js index 56bad0508..2a799b6ff 100644 --- a/isNative.js +++ b/isNative.js @@ -11,15 +11,11 @@ const reRegExpChar = /[\\^$.*+?()[\]{}|]/g; /** Used to detect host constructors (Safari). */ const reIsHostCtor = /^\[object .+?Constructor\]$/; -/** Used for built-in method references. */ -const funcProto = Function.prototype; -const objectProto = Object.prototype; - /** Used to resolve the decompiled source of functions. */ -const funcToString = funcProto.toString; +const funcToString = Function.prototype.toString; /** Used to check objects for own properties. */ -const hasOwnProperty = objectProto.hasOwnProperty; +const hasOwnProperty = Object.prototype.hasOwnProperty; /** Used to detect if a method is native. */ const reIsNative = RegExp(`^${ diff --git a/isPlainObject.js b/isPlainObject.js index d732559ab..eda0c0604 100644 --- a/isPlainObject.js +++ b/isPlainObject.js @@ -5,15 +5,11 @@ import isObjectLike from './isObjectLike.js'; /** `Object#toString` result references. */ const objectTag = '[object Object]'; -/** Used for built-in method references. */ -const funcProto = Function.prototype; -const objectProto = Object.prototype; - /** Used to resolve the decompiled source of functions. */ -const funcToString = funcProto.toString; +const funcToString = Function.prototype.toString; /** Used to check objects for own properties. */ -const hasOwnProperty = objectProto.hasOwnProperty; +const hasOwnProperty = Object.prototype.hasOwnProperty; /** Used to infer the `Object` constructor. */ const objectCtorString = funcToString.call(Object); diff --git a/join.js b/join.js index 0462ef2e0..f7ef5f5c7 100644 --- a/join.js +++ b/join.js @@ -1,8 +1,5 @@ -/** Used for built-in method references. */ -const arrayProto = Array.prototype; - /* Built-in method references for those with the same name as other `lodash` methods. */ -const nativeJoin = arrayProto.join; +const nativeJoin = Array.prototype.join; /** * Converts all elements in `array` into a string separated by `separator`. diff --git a/reverse.js b/reverse.js index 8c00fc1ae..b18b26643 100644 --- a/reverse.js +++ b/reverse.js @@ -1,8 +1,5 @@ -/** Used for built-in method references. */ -const arrayProto = Array.prototype; - /* Built-in method references for those with the same name as other `lodash` methods. */ -const nativeReverse = arrayProto.reverse; +const nativeReverse = Array.prototype.reverse; /** * Reverses `array` so that the first element becomes the last, the second