perfomance fixes, eslint fixes (#4482)

This commit is contained in:
Anatoliy Kurochkin
2019-09-26 10:58:44 +03:00
committed by John-David Dalton
parent 29eb5713f5
commit 898b378f06
73 changed files with 89 additions and 89 deletions

View File

@@ -12,7 +12,7 @@ import Hash from './Hash.js'
function getMapData({ __data__ }, key) {
const data = __data__
return isKeyable(key)
? data[typeof key == 'string' ? 'string' : 'hash']
? data[typeof key === 'string' ? 'string' : 'hash']
: data.map
}
@@ -25,7 +25,7 @@ function getMapData({ __data__ }, key) {
*/
function isKeyable(value) {
const type = typeof value
return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')
return (type === 'string' || type === 'number' || type === 'symbol' || type === 'boolean')
? (value !== '__proto__')
: (value === null)
}

View File

@@ -30,7 +30,7 @@ function arrayLikeKeys(value, inherited) {
if ((inherited || hasOwnProperty.call(value, key)) &&
!(skipIndexes && (
// Safari 9 has enumerable `arguments.length` in strict mode.
(key == 'length' ||
(key === 'length' ||
// Skip index properties.
isIndex(key, length))
))) {

View File

@@ -16,7 +16,7 @@ function assignValue(object, key, value) {
const objValue = object[key]
if (!(hasOwnProperty.call(object, key) && eq(objValue, value))) {
if (value !== 0 || (1 / value) == (1 / objValue)) {
if (value !== 0 || (1 / value) === (1 / objValue)) {
baseAssignValue(object, key, value)
}
} else if (value === undefined && !(key in object)) {

View File

@@ -131,7 +131,7 @@ function initCloneArray(array) {
const result = new array.constructor(length)
// Add properties assigned by `RegExp#exec`.
if (length && typeof array[0] == 'string' && hasOwnProperty.call(array, 'index')) {
if (length && typeof array[0] === 'string' && hasOwnProperty.call(array, 'index')) {
result.index = array.index
result.input = array.input
}
@@ -177,7 +177,7 @@ function baseClone(value, bitmask, customizer, key, object, stack) {
return copyArray(value, result)
}
} else {
const isFunc = typeof value == 'function'
const isFunc = typeof value === 'function'
if (isBuffer(value)) {
return cloneBuffer(value, isDeep)

View File

@@ -11,7 +11,7 @@ import matchesStrictComparable from './matchesStrictComparable.js'
*/
function baseMatches(source) {
const matchData = getMatchData(source)
if (matchData.length == 1 && matchData[0][2]) {
if (matchData.length === 1 && matchData[0][2]) {
return matchesStrictComparable(matchData[0][0], matchData[0][1])
}
return (object) => object === source || baseIsMatch(object, source, matchData)

View File

@@ -71,7 +71,7 @@ function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, sta
if (isArguments(objValue)) {
newValue = toPlainObject(objValue)
}
else if (typeof objValue == 'function' || !isObject(objValue)) {
else if (typeof objValue === 'function' || !isObject(objValue)) {
newValue = initCloneObject(srcValue)
}
}

View File

@@ -17,7 +17,7 @@ function basePullAt(array, indexes) {
while (length--) {
let previous
const index = indexes[length]
if (length == lastIndex || index !== previous) {
if (length === lastIndex || index !== previous) {
previous = index
if (isIndex(index)) {
array.splice(index, 1)

View File

@@ -21,7 +21,7 @@ function baseSortedIndex(array, value, retHighest) {
let low = 0
let high = array == null ? low : array.length
if (typeof value == 'number' && value === value && high <= HALF_MAX_ARRAY_LENGTH) {
if (typeof value === 'number' && value === value && high <= HALF_MAX_ARRAY_LENGTH) {
while (low < high) {
const mid = (low + high) >>> 1
const computed = array[mid]

View File

@@ -12,7 +12,7 @@ const NAN = 0 / 0
* @returns {number} Returns the number.
*/
function baseToNumber(value) {
if (typeof value == 'number') {
if (typeof value === 'number') {
return value
}
if (isSymbol(value)) {

View File

@@ -16,7 +16,7 @@ const symbolToString = Symbol.prototype.toString
*/
function baseToString(value) {
// Exit early for strings to avoid a performance hit in some environments.
if (typeof value == 'string') {
if (typeof value === 'string') {
return value
}
if (Array.isArray(value)) {

View File

@@ -1,10 +1,10 @@
import root from './root.js'
/** Detect free variable `exports`. */
const freeExports = typeof exports == 'object' && exports !== null && !exports.nodeType && exports
const freeExports = typeof exports === 'object' && exports !== null && !exports.nodeType && exports
/** Detect free variable `module`. */
const freeModule = freeExports && typeof module == 'object' && module !== null && !module.nodeType && module
const freeModule = freeExports && typeof module === 'object' && module !== null && !module.nodeType && module
/** Detect the popular CommonJS extension `module.exports`. */
const moduleExports = freeModule && freeModule.exports === freeExports

View File

@@ -20,7 +20,7 @@ function compareAscending(value, other) {
const othIsReflexive = other === other
const othIsSymbol = isSymbol(other)
const val = typeof value == 'string'
const val = typeof value === 'string'
? value.localeCompare(other)
: -other

View File

@@ -14,7 +14,7 @@ function createAssigner(assigner) {
let customizer = length > 1 ? sources[length - 1] : undefined
const guard = length > 2 ? sources[2] : undefined
customizer = (assigner.length > 3 && typeof customizer == 'function')
customizer = (assigner.length > 3 && typeof customizer === 'function')
? (length--, customizer)
: undefined

View File

@@ -75,8 +75,8 @@ function equalObjects(object, other, bitmask, customizer, equalFunc, stack) {
// Non `Object` object instances with different constructors are not equal.
if (objCtor != othCtor &&
('constructor' in object && 'constructor' in other) &&
!(typeof objCtor == 'function' && objCtor instanceof objCtor &&
typeof othCtor == 'function' && othCtor instanceof othCtor)) {
!(typeof objCtor === 'function' && objCtor instanceof objCtor &&
typeof othCtor === 'function' && othCtor instanceof othCtor)) {
result = false
}
}

View File

@@ -1,4 +1,4 @@
/** Detect free variable `global` from Node.js. */
const freeGlobal = typeof global == 'object' && global !== null && global.Object === Object && global
const freeGlobal = typeof global === 'object' && global !== null && global.Object === Object && global
export default freeGlobal

View File

@@ -8,7 +8,7 @@ import isPrototype from './isPrototype.js'
* @returns {Object} Returns the initialized clone.
*/
function initCloneObject(object) {
return (typeof object.constructor == 'function' && !isPrototype(object))
return (typeof object.constructor === 'function' && !isPrototype(object))
? Object.create(Object.getPrototypeOf(object))
: {}
}

View File

@@ -17,8 +17,8 @@ function isIndex(value, length) {
length = length == null ? MAX_SAFE_INTEGER : length
return !!length &&
(type == 'number' ||
(type != 'symbol' && reIsUint.test(value))) &&
(type === 'number' ||
(type !== 'symbol' && reIsUint.test(value))) &&
(value > -1 && value % 1 == 0 && value < length)
}

View File

@@ -19,9 +19,9 @@ function isIterateeCall(value, index, object) {
return false
}
const type = typeof index
if (type == 'number'
if (type === 'number'
? (isArrayLike(object) && isIndex(index, object.length))
: (type == 'string' && index in object)
: (type === 'string' && index in object)
) {
return eq(object[index], value)
}

View File

@@ -17,7 +17,7 @@ function isKey(value, object) {
return false
}
const type = typeof value
if (type == 'number' || type == 'boolean' || value == null || isSymbol(value)) {
if (type === 'number' || type === 'boolean' || value == null || isSymbol(value)) {
return true
}
return reIsPlainProp.test(value) || !reIsDeepProp.test(value) ||

View File

@@ -10,7 +10,7 @@ const objectProto = Object.prototype
*/
function isPrototype(value) {
const Ctor = value && value.constructor
const proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto
const proto = (typeof Ctor === 'function' && Ctor.prototype) || objectProto
return value === proto
}

View File

@@ -1,10 +1,10 @@
import freeGlobal from './freeGlobal.js'
/** Detect free variable `exports`. */
const freeExports = typeof exports == 'object' && exports !== null && !exports.nodeType && exports
const freeExports = typeof exports === 'object' && exports !== null && !exports.nodeType && exports
/** Detect free variable `module`. */
const freeModule = freeExports && typeof module == 'object' && module !== null && !module.nodeType && module
const freeModule = freeExports && typeof module === 'object' && module !== null && !module.nodeType && module
/** Detect the popular CommonJS extension `module.exports`. */
const moduleExports = freeModule && freeModule.exports === freeExports

View File

@@ -2,10 +2,10 @@
import freeGlobal from './freeGlobal.js'
/** Detect free variable `globalThis` */
const freeGlobalThis = typeof globalThis == 'object' && globalThis !== null && globalThis.Object == Object && globalThis
const freeGlobalThis = typeof globalThis === 'object' && globalThis !== null && globalThis.Object == Object && globalThis
/** Detect free variable `self`. */
const freeSelf = typeof self == 'object' && self !== null && self.Object === Object && self
const freeSelf = typeof self === 'object' && self !== null && self.Object === Object && self
/** Used as a reference to the global object. */
const root = freeGlobalThis || freeGlobal || freeSelf || Function('return this')()

View File

@@ -11,7 +11,7 @@ const INFINITY = 1 / 0
* @returns {string|symbol} Returns the key.
*/
function toKey(value) {
if (typeof value == 'string' || isSymbol(value)) {
if (typeof value === 'string' || isSymbol(value)) {
return value
}
const result = `${value}`