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) { function getMapData({ __data__ }, key) {
const data = __data__ const data = __data__
return isKeyable(key) return isKeyable(key)
? data[typeof key == 'string' ? 'string' : 'hash'] ? data[typeof key === 'string' ? 'string' : 'hash']
: data.map : data.map
} }
@@ -25,7 +25,7 @@ function getMapData({ __data__ }, key) {
*/ */
function isKeyable(value) { function isKeyable(value) {
const type = typeof 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 !== '__proto__')
: (value === null) : (value === null)
} }

View File

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

View File

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

View File

@@ -131,7 +131,7 @@ function initCloneArray(array) {
const result = new array.constructor(length) const result = new array.constructor(length)
// Add properties assigned by `RegExp#exec`. // 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.index = array.index
result.input = array.input result.input = array.input
} }
@@ -177,7 +177,7 @@ function baseClone(value, bitmask, customizer, key, object, stack) {
return copyArray(value, result) return copyArray(value, result)
} }
} else { } else {
const isFunc = typeof value == 'function' const isFunc = typeof value === 'function'
if (isBuffer(value)) { if (isBuffer(value)) {
return cloneBuffer(value, isDeep) return cloneBuffer(value, isDeep)

View File

@@ -11,7 +11,7 @@ import matchesStrictComparable from './matchesStrictComparable.js'
*/ */
function baseMatches(source) { function baseMatches(source) {
const matchData = getMatchData(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 matchesStrictComparable(matchData[0][0], matchData[0][1])
} }
return (object) => object === source || baseIsMatch(object, source, matchData) 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)) { if (isArguments(objValue)) {
newValue = toPlainObject(objValue) newValue = toPlainObject(objValue)
} }
else if (typeof objValue == 'function' || !isObject(objValue)) { else if (typeof objValue === 'function' || !isObject(objValue)) {
newValue = initCloneObject(srcValue) newValue = initCloneObject(srcValue)
} }
} }

View File

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

View File

@@ -21,7 +21,7 @@ function baseSortedIndex(array, value, retHighest) {
let low = 0 let low = 0
let high = array == null ? low : array.length 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) { while (low < high) {
const mid = (low + high) >>> 1 const mid = (low + high) >>> 1
const computed = array[mid] const computed = array[mid]

View File

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

View File

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

View File

@@ -1,10 +1,10 @@
import root from './root.js' import root from './root.js'
/** Detect free variable `exports`. */ /** 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`. */ /** 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`. */ /** Detect the popular CommonJS extension `module.exports`. */
const moduleExports = freeModule && freeModule.exports === freeExports const moduleExports = freeModule && freeModule.exports === freeExports

View File

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

View File

@@ -14,7 +14,7 @@ function createAssigner(assigner) {
let customizer = length > 1 ? sources[length - 1] : undefined let customizer = length > 1 ? sources[length - 1] : undefined
const guard = length > 2 ? sources[2] : undefined const guard = length > 2 ? sources[2] : undefined
customizer = (assigner.length > 3 && typeof customizer == 'function') customizer = (assigner.length > 3 && typeof customizer === 'function')
? (length--, customizer) ? (length--, customizer)
: undefined : 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. // Non `Object` object instances with different constructors are not equal.
if (objCtor != othCtor && if (objCtor != othCtor &&
('constructor' in object && 'constructor' in other) && ('constructor' in object && 'constructor' in other) &&
!(typeof objCtor == 'function' && objCtor instanceof objCtor && !(typeof objCtor === 'function' && objCtor instanceof objCtor &&
typeof othCtor == 'function' && othCtor instanceof othCtor)) { typeof othCtor === 'function' && othCtor instanceof othCtor)) {
result = false result = false
} }
} }

View File

@@ -1,4 +1,4 @@
/** Detect free variable `global` from Node.js. */ /** 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 export default freeGlobal

View File

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

View File

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

View File

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

View File

@@ -17,7 +17,7 @@ function isKey(value, object) {
return false return false
} }
const type = typeof value 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 true
} }
return reIsPlainProp.test(value) || !reIsDeepProp.test(value) || return reIsPlainProp.test(value) || !reIsDeepProp.test(value) ||

View File

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

View File

@@ -1,10 +1,10 @@
import freeGlobal from './freeGlobal.js' import freeGlobal from './freeGlobal.js'
/** Detect free variable `exports`. */ /** 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`. */ /** 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`. */ /** Detect the popular CommonJS extension `module.exports`. */
const moduleExports = freeModule && freeModule.exports === freeExports const moduleExports = freeModule && freeModule.exports === freeExports

View File

@@ -2,10 +2,10 @@
import freeGlobal from './freeGlobal.js' import freeGlobal from './freeGlobal.js'
/** Detect free variable `globalThis` */ /** 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`. */ /** 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. */ /** Used as a reference to the global object. */
const root = freeGlobalThis || freeGlobal || freeSelf || Function('return this')() const root = freeGlobalThis || freeGlobal || freeSelf || Function('return this')()

View File

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

View File

@@ -16,7 +16,7 @@
* // => Logs 'done saving!' after the two async saves have completed. * // => Logs 'done saving!' after the two async saves have completed.
*/ */
function after(n, func) { function after(n, func) {
if (typeof func != 'function') { if (typeof func !== 'function') {
throw new TypeError('Expected a function') throw new TypeError('Expected a function')
} }
n = n || 0 n = n || 0

View File

@@ -15,7 +15,7 @@
*/ */
function before(n, func) { function before(n, func) {
let result let result
if (typeof func != 'function') { if (typeof func !== 'function') {
throw new TypeError('Expected a function') throw new TypeError('Expected a function')
} }
return function(...args) { return function(...args) {

View File

@@ -33,7 +33,7 @@ const CLONE_SYMBOLS_FLAG = 4
* // => 20 * // => 20
*/ */
function cloneDeepWith(value, customizer) { function cloneDeepWith(value, customizer) {
customizer = typeof customizer == 'function' ? customizer : undefined customizer = typeof customizer === 'function' ? customizer : undefined
return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG, customizer) return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG, customizer)
} }

View File

@@ -33,7 +33,7 @@ const CLONE_SYMBOLS_FLAG = 4
* // => 0 * // => 0
*/ */
function cloneWith(value, customizer) { function cloneWith(value, customizer) {
customizer = typeof customizer == 'function' ? customizer : undefined customizer = typeof customizer === 'function' ? customizer : undefined
return baseClone(value, CLONE_SYMBOLS_FLAG, customizer) return baseClone(value, CLONE_SYMBOLS_FLAG, customizer)
} }

View File

@@ -31,7 +31,7 @@ function cond(pairs) {
const length = pairs == null ? 0 : pairs.length const length = pairs == null ? 0 : pairs.length
pairs = !length ? [] : map(pairs, (pair) => { pairs = !length ? [] : map(pairs, (pair) => {
if (typeof pair[1] != 'function') { if (typeof pair[1] !== 'function') {
throw new TypeError('Expected a function') throw new TypeError('Expected a function')
} }
return [pair[0], pair[1]] return [pair[0], pair[1]]

View File

@@ -13,7 +13,7 @@
* // => Logs 'deferred' after one millisecond. * // => Logs 'deferred' after one millisecond.
*/ */
function defer(func, ...args) { function defer(func, ...args) {
if (typeof func != 'function') { if (typeof func !== 'function') {
throw new TypeError('Expected a function') throw new TypeError('Expected a function')
} }
return setTimeout(func, 1, ...args) return setTimeout(func, 1, ...args)

View File

@@ -14,7 +14,7 @@
* // => Logs 'later' after one second. * // => Logs 'later' after one second.
*/ */
function delay(func, wait, ...args) { function delay(func, wait, ...args) {
if (typeof func != 'function') { if (typeof func !== 'function') {
throw new TypeError('Expected a function') throw new TypeError('Expected a function')
} }
return setTimeout(func, +wait || 0, ...args) return setTimeout(func, +wait || 0, ...args)

View File

@@ -14,7 +14,7 @@
* // => ['d', 'c', 'b', 'a'] * // => ['d', 'c', 'b', 'a']
*/ */
function flip(func) { function flip(func) {
if (typeof func != 'function') { if (typeof func !== 'function') {
throw new TypeError('Expected a function') throw new TypeError('Expected a function')
} }
return function(...args) { return function(...args) {

View File

@@ -11,7 +11,7 @@
* @example * @example
* *
* import add from 'lodash/add' * import add from 'lodash/add'
* *
* function square(n) { * function square(n) {
* return n * n * return n * n
* } * }
@@ -24,7 +24,7 @@ function flow(...funcs) {
const length = funcs ? funcs.length : 0 const length = funcs ? funcs.length : 0
let index = length let index = length
while (index--) { while (index--) {
if (typeof funcs[index] != 'function') { if (typeof funcs[index] !== 'function') {
throw new TypeError('Expected a function') throw new TypeError('Expected a function')
} }
} }

View File

@@ -12,7 +12,7 @@ import flow from './flow.js'
* @example * @example
* *
* import add from 'lodash/add' * import add from 'lodash/add'
* *
* function square(n) { * function square(n) {
* return n * n * return n * n
* } * }

View File

@@ -23,7 +23,7 @@ function functions(object) {
if (object == null) { if (object == null) {
return [] return []
} }
return Object.keys(object).filter((key) => typeof object[key] == 'function') return Object.keys(object).filter((key) => typeof object[key] === 'function')
} }
export default functions export default functions

2
gt.js
View File

@@ -20,7 +20,7 @@
* // => false * // => false
*/ */
function gt(value, other) { function gt(value, other) {
if (!(typeof value == 'string' && typeof other == 'string')) { if (!(typeof value === 'string' && typeof other === 'string')) {
value = +value value = +value
other = +other other = +other
} }

2
gte.js
View File

@@ -20,7 +20,7 @@
* // => false * // => false
*/ */
function gte(value, other) { function gte(value, other) {
if (!(typeof value == 'string' && typeof other == 'string')) { if (!(typeof value === 'string' && typeof other === 'string')) {
value = +value value = +value
other = +other other = +other
} }

View File

@@ -26,7 +26,7 @@ function intersectionWith(...arrays) {
let comparator = last(arrays) let comparator = last(arrays)
const mapped = map(arrays, castArrayLikeObject) const mapped = map(arrays, castArrayLikeObject)
comparator = typeof comparator == 'function' ? comparator : undefined comparator = typeof comparator === 'function' ? comparator : undefined
if (comparator) { if (comparator) {
mapped.pop() mapped.pop()
} }

View File

@@ -20,7 +20,7 @@ function invert(object) {
const result = {} const result = {}
Object.keys(object).forEach((key) => { Object.keys(object).forEach((key) => {
let value = object[key] let value = object[key]
if (value != null && typeof value.toString != 'function') { if (value != null && typeof value.toString !== 'function') {
value = toString.call(value) value = toString.call(value)
} }
result[value] = key result[value] = key

View File

@@ -25,7 +25,7 @@ import isArrayLike from './isArrayLike.js'
*/ */
function invokeMap(collection, path, args) { function invokeMap(collection, path, args) {
let index = -1 let index = -1
const isFunc = typeof path == 'function' const isFunc = typeof path === 'function'
const result = isArrayLike(collection) ? new Array(collection.length) : [] const result = isArrayLike(collection) ? new Array(collection.length) : []
baseEach(collection, (value) => { baseEach(collection, (value) => {

View File

@@ -24,7 +24,7 @@ import isLength from './isLength.js'
* // => false * // => false
*/ */
function isArrayLike(value) { function isArrayLike(value) {
return value != null && typeof value != 'function' && isLength(value.length) return value != null && typeof value !== 'function' && isLength(value.length)
} }
export default isArrayLike export default isArrayLike

View File

@@ -1,10 +1,10 @@
import root from './.internal/root.js' import root from './.internal/root.js'
/** Detect free variable `exports`. */ /** 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`. */ /** 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`. */ /** Detect the popular CommonJS extension `module.exports`. */
const moduleExports = freeModule && freeModule.exports === freeExports const moduleExports = freeModule && freeModule.exports === freeExports

View File

@@ -47,7 +47,7 @@ function isEmpty(value) {
return true return true
} }
if (isArrayLike(value) && if (isArrayLike(value) &&
(Array.isArray(value) || typeof value == 'string' || typeof value.splice == 'function' || (Array.isArray(value) || typeof value === 'string' || typeof value.splice === 'function' ||
isBuffer(value) || isTypedArray(value) || isArguments(value))) { isBuffer(value) || isTypedArray(value) || isArguments(value))) {
return !value.length return !value.length
} }

View File

@@ -31,7 +31,7 @@ import baseIsEqual from './.internal/baseIsEqual.js'
* // => true * // => true
*/ */
function isEqualWith(value, other, customizer) { function isEqualWith(value, other, customizer) {
customizer = typeof customizer == 'function' ? customizer : undefined customizer = typeof customizer === 'function' ? customizer : undefined
const result = customizer ? customizer(value, other) : undefined const result = customizer ? customizer(value, other) : undefined
return result === undefined ? baseIsEqual(value, other, undefined, customizer) : !!result return result === undefined ? baseIsEqual(value, other, undefined, customizer) : !!result
} }

View File

@@ -24,7 +24,7 @@ function isError(value) {
} }
const tag = getTag(value) const tag = getTag(value)
return tag == '[object Error]' || tag == '[object DOMException]' || return tag == '[object Error]' || tag == '[object DOMException]' ||
(typeof value.message == 'string' && typeof value.name == 'string' && !isPlainObject(value)) (typeof value.message === 'string' && typeof value.name === 'string' && !isPlainObject(value))
} }
export default isError export default isError

View File

@@ -26,7 +26,7 @@ const MAX_SAFE_INTEGER = 9007199254740991
* // => false * // => false
*/ */
function isLength(value) { function isLength(value) {
return typeof value == 'number' && return typeof value === 'number' &&
value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER
} }

View File

@@ -32,7 +32,7 @@ import getMatchData from './.internal/getMatchData.js'
* // => true * // => true
*/ */
function isMatchWith(object, source, customizer) { function isMatchWith(object, source, customizer) {
customizer = typeof customizer == 'function' ? customizer : undefined customizer = typeof customizer === 'function' ? customizer : undefined
return baseIsMatch(object, source, getMatchData(source), customizer) return baseIsMatch(object, source, getMatchData(source), customizer)
} }

View File

@@ -27,7 +27,7 @@ import isObjectLike from './isObjectLike.js'
* // => false * // => false
*/ */
function isNumber(value) { function isNumber(value) {
return typeof value == 'number' || return typeof value === 'number' ||
(isObjectLike(value) && getTag(value) == '[object Number]') (isObjectLike(value) && getTag(value) == '[object Number]')
} }

View File

@@ -23,7 +23,7 @@
*/ */
function isObject(value) { function isObject(value) {
const type = typeof value const type = typeof value
return value != null && (type == 'object' || type == 'function') return value != null && (type === 'object' || type === 'function')
} }
export default isObject export default isObject

View File

@@ -21,7 +21,7 @@
* // => false * // => false
*/ */
function isObjectLike(value) { function isObjectLike(value) {
return typeof value == 'object' && value !== null return typeof value === 'object' && value !== null
} }
export default isObjectLike export default isObjectLike

View File

@@ -17,7 +17,7 @@ import getTag from './.internal/getTag.js'
*/ */
function isString(value) { function isString(value) {
const type = typeof value const type = typeof value
return type == 'string' || (type == 'object' && value != null && !Array.isArray(value) && getTag(value) == '[object String]') return type === 'string' || (type === 'object' && value != null && !Array.isArray(value) && getTag(value) == '[object String]')
} }
export default isString export default isString

View File

@@ -17,7 +17,7 @@ import getTag from './.internal/getTag.js'
*/ */
function isSymbol(value) { function isSymbol(value) {
const type = typeof value const type = typeof value
return type == 'symbol' || (type == 'object' && value != null && getTag(value) == '[object Symbol]') return type == 'symbol' || (type === 'object' && value != null && getTag(value) == '[object Symbol]')
} }
export default isSymbol export default isSymbol

2
lt.js
View File

@@ -20,7 +20,7 @@
* // => false * // => false
*/ */
function lt(value, other) { function lt(value, other) {
if (!(typeof value == 'string' && typeof other == 'string')) { if (!(typeof value === 'string' && typeof other === 'string')) {
value = +value value = +value
other = +other other = +other
} }

2
lte.js
View File

@@ -20,7 +20,7 @@
* // => false * // => false
*/ */
function lte(value, other) { function lte(value, other) {
if (!(typeof value == 'string' && typeof other == 'string')) { if (!(typeof value === 'string' && typeof other === 'string')) {
value = +value value = +value
other = +other other = +other
} }

View File

@@ -41,7 +41,7 @@
* memoize.Cache = WeakMap * memoize.Cache = WeakMap
*/ */
function memoize(func, resolver) { function memoize(func, resolver) {
if (typeof func != 'function' || (resolver != null && typeof resolver != 'function')) { if (typeof func !== 'function' || (resolver != null && typeof resolver !== 'function')) {
throw new TypeError('Expected a function') throw new TypeError('Expected a function')
} }
const memoized = function(...args) { const memoized = function(...args) {

View File

@@ -17,7 +17,7 @@
* // => [1, 3, 5] * // => [1, 3, 5]
*/ */
function negate(predicate) { function negate(predicate) {
if (typeof predicate != 'function') { if (typeof predicate !== 'function') {
throw new TypeError('Expected a function') throw new TypeError('Expected a function')
} }
return function(...args) { return function(...args) {

View File

@@ -35,11 +35,11 @@ const freeParseFloat = parseFloat
*/ */
function random(lower, upper, floating) { function random(lower, upper, floating) {
if (floating === undefined) { if (floating === undefined) {
if (typeof upper == 'boolean') { if (typeof upper === 'boolean') {
floating = upper floating = upper
upper = undefined upper = undefined
} }
else if (typeof lower == 'boolean') { else if (typeof lower === 'boolean') {
floating = lower floating = lower
lower = undefined lower = undefined
} }

View File

@@ -45,7 +45,7 @@ function result(object, path, defaultValue) {
index = length index = length
value = defaultValue value = defaultValue
} }
object = typeof value == 'function' ? value.call(object) : value object = typeof value === 'function' ? value.call(object) : value
} }
return object return object
} }

View File

@@ -23,7 +23,7 @@ import baseSet from './.internal/baseSet.js'
* // => { '0': { '1': 'a' } } * // => { '0': { '1': 'a' } }
*/ */
function setWith(object, path, value, customizer) { function setWith(object, path, value, customizer) {
customizer = typeof customizer == 'function' ? customizer : undefined customizer = typeof customizer === 'function' ? customizer : undefined
return object == null ? object : baseSet(object, path, value, customizer) return object == null ? object : baseSet(object, path, value, customizer)
} }

View File

@@ -29,7 +29,7 @@ function split(string, separator, limit) {
return [] return []
} }
if (string && ( if (string && (
typeof separator == 'string' || typeof separator === 'string' ||
(separator != null && !isRegExp(separator)) (separator != null && !isRegExp(separator))
)) { )) {
if (!separator && hasUnicode(string)) { if (!separator && hasUnicode(string)) {

View File

@@ -42,7 +42,7 @@ describe(basename, function() {
var attempt = function() { var attempt = function() {
var actual = _VERSION; var actual = _VERSION;
if ((new Date - start) < limit && typeof actual != 'string') { if ((new Date - start) < limit && typeof actual !== 'string') {
setTimeout(attempt, 16); setTimeout(attempt, 16);
return; return;
} }

View File

@@ -195,7 +195,7 @@ describe('bind', function() {
it('should not error when calling bound class constructors with the `new` operator', function() { it('should not error when calling bound class constructors with the `new` operator', function() {
var createCtor = lodashStable.attempt(Function, '"use strict";return class A{}'); var createCtor = lodashStable.attempt(Function, '"use strict";return class A{}');
if (typeof createCtor == 'function') { if (typeof createCtor === 'function') {
var bound = bind(createCtor()), var bound = bind(createCtor()),
count = 8, count = 8,
expected = lodashStable.times(count, stubTrue); expected = lodashStable.times(count, stubTrue);

View File

@@ -25,11 +25,11 @@ describe('isFunction', function() {
}); });
it('should return `true` for async functions', function() { it('should return `true` for async functions', function() {
assert.strictEqual(isFunction(asyncFunc), typeof asyncFunc == 'function'); assert.strictEqual(isFunction(asyncFunc), typeof asyncFunc === 'function');
}); });
it('should return `true` for generator functions', function() { it('should return `true` for generator functions', function() {
assert.strictEqual(isFunction(genFunc), typeof genFunc == 'function'); assert.strictEqual(isFunction(genFunc), typeof genFunc === 'function');
}); });
it('should return `true` for the `Proxy` constructor', function() { it('should return `true` for the `Proxy` constructor', function() {

View File

@@ -12,7 +12,7 @@ describe('isNumber', function() {
it('should return `false` for non-numbers', function() { it('should return `false` for non-numbers', function() {
var expected = lodashStable.map(falsey, function(value) { var expected = lodashStable.map(falsey, function(value) {
return typeof value == 'number'; return typeof value === 'number';
}); });
var actual = lodashStable.map(falsey, function(value, index) { var actual = lodashStable.map(falsey, function(value, index) {

View File

@@ -139,7 +139,7 @@ describe('keys methods', function() {
it('`_.' + methodName + '` should coerce primitives to objects (test in IE 9)', function() { it('`_.' + methodName + '` should coerce primitives to objects (test in IE 9)', function() {
var expected = lodashStable.map(primitives, function(value) { var expected = lodashStable.map(primitives, function(value) {
return typeof value == 'string' ? ['0'] : []; return typeof value === 'string' ? ['0'] : [];
}); });
var actual = lodashStable.map(primitives, func); var actual = lodashStable.map(primitives, func);

View File

@@ -24,7 +24,7 @@ var funcTag = '[object Function]',
objectTag = '[object Object]'; objectTag = '[object Object]';
/** Used as a reference to the global object. */ /** Used as a reference to the global object. */
var root = (typeof global == 'object' && global) || this; var root = (typeof global === 'object' && global) || this;
/** Used to store lodash to test for bad extensions/shims. */ /** Used to store lodash to test for bad extensions/shims. */
var lodashBizarro = root.lodashBizarro; var lodashBizarro = root.lodashBizarro;
@@ -246,7 +246,7 @@ var isModularize = ui.isModularize;
var isNpm = isModularize && /\bnpm\b/.test([ui.buildPath, ui.urlParams.build]); var isNpm = isModularize && /\bnpm\b/.test([ui.buildPath, ui.urlParams.build]);
/** Detect if running in PhantomJS. */ /** Detect if running in PhantomJS. */
var isPhantom = phantom || (typeof callPhantom == 'function'); var isPhantom = phantom || (typeof callPhantom === 'function');
/** Detect if lodash is in strict mode. */ /** Detect if lodash is in strict mode. */
var isStrict = ui.isStrict; var isStrict = ui.isStrict;
@@ -459,7 +459,7 @@ function toArgs(array) {
// Add bizarro values. // Add bizarro values.
(function() { (function() {
return; // fixme return; // fixme
if (document || (typeof require != 'function')) { if (document || (typeof require !== 'function')) {
return; return;
} }
var nativeString = fnToString.call(toString), var nativeString = fnToString.call(toString),

View File

@@ -42,17 +42,17 @@ const freeParseInt = parseInt
* // => 3.2 * // => 3.2
*/ */
function toNumber(value) { function toNumber(value) {
if (typeof value == 'number') { if (typeof value === 'number') {
return value return value
} }
if (isSymbol(value)) { if (isSymbol(value)) {
return NAN return NAN
} }
if (isObject(value)) { if (isObject(value)) {
const other = typeof value.valueOf == 'function' ? value.valueOf() : value const other = typeof value.valueOf === 'function' ? value.valueOf() : value
value = isObject(other) ? `${other}` : other value = isObject(other) ? `${other}` : other
} }
if (typeof value != 'string') { if (typeof value !== 'string') {
return value === 0 ? value : +value return value === 0 ? value : +value
} }
value = value.replace(reTrim, '') value = value.replace(reTrim, '')

View File

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

View File

@@ -43,7 +43,7 @@ function transform(object, iteratee, accumulator) {
accumulator = isArr ? new Ctor : [] accumulator = isArr ? new Ctor : []
} }
else if (isObject(object)) { else if (isObject(object)) {
accumulator = typeof Ctor == 'function' accumulator = typeof Ctor === 'function'
? Object.create(Object.getPrototypeOf(object)) ? Object.create(Object.getPrototypeOf(object))
: {} : {}
} }

View File

@@ -25,7 +25,7 @@ import last from './last.js'
*/ */
function unionWith(...arrays) { function unionWith(...arrays) {
let comparator = last(arrays) let comparator = last(arrays)
comparator = typeof comparator == 'function' ? comparator : undefined comparator = typeof comparator === 'function' ? comparator : undefined
return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true), undefined, comparator) return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true), undefined, comparator)
} }

View File

@@ -20,7 +20,7 @@ import baseUniq from './.internal/baseUniq.js'
* // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }] * // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]
*/ */
function uniqWith(array, comparator) { function uniqWith(array, comparator) {
comparator = typeof comparator == 'function' ? comparator : undefined comparator = typeof comparator === 'function' ? comparator : undefined
return (array != null && array.length) return (array != null && array.length)
? baseUniq(array, undefined, comparator) ? baseUniq(array, undefined, comparator)
: [] : []

View File

@@ -23,7 +23,7 @@ import baseUpdate from './.internal/baseUpdate.js'
* // => { '0': { '1': 'a' } } * // => { '0': { '1': 'a' } }
*/ */
function updateWith(object, path, updater, customizer) { function updateWith(object, path, updater, customizer) {
customizer = typeof customizer == 'function' ? customizer : undefined customizer = typeof customizer === 'function' ? customizer : undefined
return object == null ? object : baseUpdate(object, path, updater, customizer) return object == null ? object : baseUpdate(object, path, updater, customizer)
} }

View File

@@ -24,7 +24,7 @@ import last from './last.js'
*/ */
function xorWith(...arrays) { function xorWith(...arrays) {
let comparator = last(arrays) let comparator = last(arrays)
comparator = typeof comparator == 'function' ? comparator : undefined comparator = typeof comparator === 'function' ? comparator : undefined
return baseXor(arrays.filter(isArrayLikeObject), undefined, comparator) return baseXor(arrays.filter(isArrayLikeObject), undefined, comparator)
} }

View File

@@ -20,7 +20,7 @@ import unzipWith from './unzipWith.js'
function zipWith(...arrays) { function zipWith(...arrays) {
const length = arrays.length const length = arrays.length
let iteratee = length > 1 ? arrays[length - 1] : undefined let iteratee = length > 1 ? arrays[length - 1] : undefined
iteratee = typeof iteratee == 'function' ? (arrays.pop(), iteratee) : undefined iteratee = typeof iteratee === 'function' ? (arrays.pop(), iteratee) : undefined
return unzipWith(arrays, iteratee) return unzipWith(arrays, iteratee)
} }