mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-01-29 06:27:49 +00:00
perfomance fixes, eslint fixes (#4482)
This commit is contained in:
committed by
John-David Dalton
parent
29eb5713f5
commit
898b378f06
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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))
|
||||
))) {
|
||||
|
||||
@@ -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)) {
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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]
|
||||
|
||||
@@ -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)) {
|
||||
|
||||
@@ -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)) {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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))
|
||||
: {}
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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) ||
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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')()
|
||||
|
||||
@@ -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}`
|
||||
|
||||
2
after.js
2
after.js
@@ -16,7 +16,7 @@
|
||||
* // => Logs 'done saving!' after the two async saves have completed.
|
||||
*/
|
||||
function after(n, func) {
|
||||
if (typeof func != 'function') {
|
||||
if (typeof func !== 'function') {
|
||||
throw new TypeError('Expected a function')
|
||||
}
|
||||
n = n || 0
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
*/
|
||||
function before(n, func) {
|
||||
let result
|
||||
if (typeof func != 'function') {
|
||||
if (typeof func !== 'function') {
|
||||
throw new TypeError('Expected a function')
|
||||
}
|
||||
return function(...args) {
|
||||
|
||||
@@ -33,7 +33,7 @@ const CLONE_SYMBOLS_FLAG = 4
|
||||
* // => 20
|
||||
*/
|
||||
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)
|
||||
}
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ const CLONE_SYMBOLS_FLAG = 4
|
||||
* // => 0
|
||||
*/
|
||||
function cloneWith(value, customizer) {
|
||||
customizer = typeof customizer == 'function' ? customizer : undefined
|
||||
customizer = typeof customizer === 'function' ? customizer : undefined
|
||||
return baseClone(value, CLONE_SYMBOLS_FLAG, customizer)
|
||||
}
|
||||
|
||||
|
||||
2
cond.js
2
cond.js
@@ -31,7 +31,7 @@ function cond(pairs) {
|
||||
const length = pairs == null ? 0 : pairs.length
|
||||
|
||||
pairs = !length ? [] : map(pairs, (pair) => {
|
||||
if (typeof pair[1] != 'function') {
|
||||
if (typeof pair[1] !== 'function') {
|
||||
throw new TypeError('Expected a function')
|
||||
}
|
||||
return [pair[0], pair[1]]
|
||||
|
||||
2
defer.js
2
defer.js
@@ -13,7 +13,7 @@
|
||||
* // => Logs 'deferred' after one millisecond.
|
||||
*/
|
||||
function defer(func, ...args) {
|
||||
if (typeof func != 'function') {
|
||||
if (typeof func !== 'function') {
|
||||
throw new TypeError('Expected a function')
|
||||
}
|
||||
return setTimeout(func, 1, ...args)
|
||||
|
||||
2
delay.js
2
delay.js
@@ -14,7 +14,7 @@
|
||||
* // => Logs 'later' after one second.
|
||||
*/
|
||||
function delay(func, wait, ...args) {
|
||||
if (typeof func != 'function') {
|
||||
if (typeof func !== 'function') {
|
||||
throw new TypeError('Expected a function')
|
||||
}
|
||||
return setTimeout(func, +wait || 0, ...args)
|
||||
|
||||
2
flip.js
2
flip.js
@@ -14,7 +14,7 @@
|
||||
* // => ['d', 'c', 'b', 'a']
|
||||
*/
|
||||
function flip(func) {
|
||||
if (typeof func != 'function') {
|
||||
if (typeof func !== 'function') {
|
||||
throw new TypeError('Expected a function')
|
||||
}
|
||||
return function(...args) {
|
||||
|
||||
4
flow.js
4
flow.js
@@ -11,7 +11,7 @@
|
||||
* @example
|
||||
*
|
||||
* import add from 'lodash/add'
|
||||
*
|
||||
*
|
||||
* function square(n) {
|
||||
* return n * n
|
||||
* }
|
||||
@@ -24,7 +24,7 @@ function flow(...funcs) {
|
||||
const length = funcs ? funcs.length : 0
|
||||
let index = length
|
||||
while (index--) {
|
||||
if (typeof funcs[index] != 'function') {
|
||||
if (typeof funcs[index] !== 'function') {
|
||||
throw new TypeError('Expected a function')
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ import flow from './flow.js'
|
||||
* @example
|
||||
*
|
||||
* import add from 'lodash/add'
|
||||
*
|
||||
*
|
||||
* function square(n) {
|
||||
* return n * n
|
||||
* }
|
||||
|
||||
@@ -23,7 +23,7 @@ function functions(object) {
|
||||
if (object == null) {
|
||||
return []
|
||||
}
|
||||
return Object.keys(object).filter((key) => typeof object[key] == 'function')
|
||||
return Object.keys(object).filter((key) => typeof object[key] === 'function')
|
||||
}
|
||||
|
||||
export default functions
|
||||
|
||||
2
gt.js
2
gt.js
@@ -20,7 +20,7 @@
|
||||
* // => false
|
||||
*/
|
||||
function gt(value, other) {
|
||||
if (!(typeof value == 'string' && typeof other == 'string')) {
|
||||
if (!(typeof value === 'string' && typeof other === 'string')) {
|
||||
value = +value
|
||||
other = +other
|
||||
}
|
||||
|
||||
2
gte.js
2
gte.js
@@ -20,7 +20,7 @@
|
||||
* // => false
|
||||
*/
|
||||
function gte(value, other) {
|
||||
if (!(typeof value == 'string' && typeof other == 'string')) {
|
||||
if (!(typeof value === 'string' && typeof other === 'string')) {
|
||||
value = +value
|
||||
other = +other
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ function intersectionWith(...arrays) {
|
||||
let comparator = last(arrays)
|
||||
const mapped = map(arrays, castArrayLikeObject)
|
||||
|
||||
comparator = typeof comparator == 'function' ? comparator : undefined
|
||||
comparator = typeof comparator === 'function' ? comparator : undefined
|
||||
if (comparator) {
|
||||
mapped.pop()
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ function invert(object) {
|
||||
const result = {}
|
||||
Object.keys(object).forEach((key) => {
|
||||
let value = object[key]
|
||||
if (value != null && typeof value.toString != 'function') {
|
||||
if (value != null && typeof value.toString !== 'function') {
|
||||
value = toString.call(value)
|
||||
}
|
||||
result[value] = key
|
||||
|
||||
@@ -25,7 +25,7 @@ import isArrayLike from './isArrayLike.js'
|
||||
*/
|
||||
function invokeMap(collection, path, args) {
|
||||
let index = -1
|
||||
const isFunc = typeof path == 'function'
|
||||
const isFunc = typeof path === 'function'
|
||||
const result = isArrayLike(collection) ? new Array(collection.length) : []
|
||||
|
||||
baseEach(collection, (value) => {
|
||||
|
||||
@@ -24,7 +24,7 @@ import isLength from './isLength.js'
|
||||
* // => false
|
||||
*/
|
||||
function isArrayLike(value) {
|
||||
return value != null && typeof value != 'function' && isLength(value.length)
|
||||
return value != null && typeof value !== 'function' && isLength(value.length)
|
||||
}
|
||||
|
||||
export default isArrayLike
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import root from './.internal/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
|
||||
|
||||
@@ -47,7 +47,7 @@ function isEmpty(value) {
|
||||
return true
|
||||
}
|
||||
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))) {
|
||||
return !value.length
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ import baseIsEqual from './.internal/baseIsEqual.js'
|
||||
* // => true
|
||||
*/
|
||||
function isEqualWith(value, other, customizer) {
|
||||
customizer = typeof customizer == 'function' ? customizer : undefined
|
||||
customizer = typeof customizer === 'function' ? customizer : undefined
|
||||
const result = customizer ? customizer(value, other) : undefined
|
||||
return result === undefined ? baseIsEqual(value, other, undefined, customizer) : !!result
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ function isError(value) {
|
||||
}
|
||||
const tag = getTag(value)
|
||||
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
|
||||
|
||||
@@ -26,7 +26,7 @@ const MAX_SAFE_INTEGER = 9007199254740991
|
||||
* // => false
|
||||
*/
|
||||
function isLength(value) {
|
||||
return typeof value == 'number' &&
|
||||
return typeof value === 'number' &&
|
||||
value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER
|
||||
}
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ import getMatchData from './.internal/getMatchData.js'
|
||||
* // => true
|
||||
*/
|
||||
function isMatchWith(object, source, customizer) {
|
||||
customizer = typeof customizer == 'function' ? customizer : undefined
|
||||
customizer = typeof customizer === 'function' ? customizer : undefined
|
||||
return baseIsMatch(object, source, getMatchData(source), customizer)
|
||||
}
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ import isObjectLike from './isObjectLike.js'
|
||||
* // => false
|
||||
*/
|
||||
function isNumber(value) {
|
||||
return typeof value == 'number' ||
|
||||
return typeof value === 'number' ||
|
||||
(isObjectLike(value) && getTag(value) == '[object Number]')
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
*/
|
||||
function isObject(value) {
|
||||
const type = typeof value
|
||||
return value != null && (type == 'object' || type == 'function')
|
||||
return value != null && (type === 'object' || type === 'function')
|
||||
}
|
||||
|
||||
export default isObject
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
* // => false
|
||||
*/
|
||||
function isObjectLike(value) {
|
||||
return typeof value == 'object' && value !== null
|
||||
return typeof value === 'object' && value !== null
|
||||
}
|
||||
|
||||
export default isObjectLike
|
||||
|
||||
@@ -17,7 +17,7 @@ import getTag from './.internal/getTag.js'
|
||||
*/
|
||||
function isString(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
|
||||
|
||||
@@ -17,7 +17,7 @@ import getTag from './.internal/getTag.js'
|
||||
*/
|
||||
function isSymbol(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
|
||||
|
||||
2
lt.js
2
lt.js
@@ -20,7 +20,7 @@
|
||||
* // => false
|
||||
*/
|
||||
function lt(value, other) {
|
||||
if (!(typeof value == 'string' && typeof other == 'string')) {
|
||||
if (!(typeof value === 'string' && typeof other === 'string')) {
|
||||
value = +value
|
||||
other = +other
|
||||
}
|
||||
|
||||
2
lte.js
2
lte.js
@@ -20,7 +20,7 @@
|
||||
* // => false
|
||||
*/
|
||||
function lte(value, other) {
|
||||
if (!(typeof value == 'string' && typeof other == 'string')) {
|
||||
if (!(typeof value === 'string' && typeof other === 'string')) {
|
||||
value = +value
|
||||
other = +other
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
* memoize.Cache = WeakMap
|
||||
*/
|
||||
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')
|
||||
}
|
||||
const memoized = function(...args) {
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
* // => [1, 3, 5]
|
||||
*/
|
||||
function negate(predicate) {
|
||||
if (typeof predicate != 'function') {
|
||||
if (typeof predicate !== 'function') {
|
||||
throw new TypeError('Expected a function')
|
||||
}
|
||||
return function(...args) {
|
||||
|
||||
@@ -35,11 +35,11 @@ const freeParseFloat = parseFloat
|
||||
*/
|
||||
function random(lower, upper, floating) {
|
||||
if (floating === undefined) {
|
||||
if (typeof upper == 'boolean') {
|
||||
if (typeof upper === 'boolean') {
|
||||
floating = upper
|
||||
upper = undefined
|
||||
}
|
||||
else if (typeof lower == 'boolean') {
|
||||
else if (typeof lower === 'boolean') {
|
||||
floating = lower
|
||||
lower = undefined
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ function result(object, path, defaultValue) {
|
||||
index = length
|
||||
value = defaultValue
|
||||
}
|
||||
object = typeof value == 'function' ? value.call(object) : value
|
||||
object = typeof value === 'function' ? value.call(object) : value
|
||||
}
|
||||
return object
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ import baseSet from './.internal/baseSet.js'
|
||||
* // => { '0': { '1': 'a' } }
|
||||
*/
|
||||
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)
|
||||
}
|
||||
|
||||
|
||||
2
split.js
2
split.js
@@ -29,7 +29,7 @@ function split(string, separator, limit) {
|
||||
return []
|
||||
}
|
||||
if (string && (
|
||||
typeof separator == 'string' ||
|
||||
typeof separator === 'string' ||
|
||||
(separator != null && !isRegExp(separator))
|
||||
)) {
|
||||
if (!separator && hasUnicode(string)) {
|
||||
|
||||
@@ -42,7 +42,7 @@ describe(basename, function() {
|
||||
|
||||
var attempt = function() {
|
||||
var actual = _VERSION;
|
||||
if ((new Date - start) < limit && typeof actual != 'string') {
|
||||
if ((new Date - start) < limit && typeof actual !== 'string') {
|
||||
setTimeout(attempt, 16);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -195,7 +195,7 @@ describe('bind', 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{}');
|
||||
|
||||
if (typeof createCtor == 'function') {
|
||||
if (typeof createCtor === 'function') {
|
||||
var bound = bind(createCtor()),
|
||||
count = 8,
|
||||
expected = lodashStable.times(count, stubTrue);
|
||||
|
||||
@@ -25,11 +25,11 @@ describe('isFunction', 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() {
|
||||
assert.strictEqual(isFunction(genFunc), typeof genFunc == 'function');
|
||||
assert.strictEqual(isFunction(genFunc), typeof genFunc === 'function');
|
||||
});
|
||||
|
||||
it('should return `true` for the `Proxy` constructor', function() {
|
||||
|
||||
@@ -12,7 +12,7 @@ describe('isNumber', function() {
|
||||
|
||||
it('should return `false` for non-numbers', function() {
|
||||
var expected = lodashStable.map(falsey, function(value) {
|
||||
return typeof value == 'number';
|
||||
return typeof value === 'number';
|
||||
});
|
||||
|
||||
var actual = lodashStable.map(falsey, function(value, index) {
|
||||
|
||||
@@ -139,7 +139,7 @@ describe('keys methods', function() {
|
||||
|
||||
it('`_.' + methodName + '` should coerce primitives to objects (test in IE 9)', function() {
|
||||
var expected = lodashStable.map(primitives, function(value) {
|
||||
return typeof value == 'string' ? ['0'] : [];
|
||||
return typeof value === 'string' ? ['0'] : [];
|
||||
});
|
||||
|
||||
var actual = lodashStable.map(primitives, func);
|
||||
|
||||
@@ -24,7 +24,7 @@ var funcTag = '[object Function]',
|
||||
objectTag = '[object 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. */
|
||||
var lodashBizarro = root.lodashBizarro;
|
||||
@@ -246,7 +246,7 @@ var isModularize = ui.isModularize;
|
||||
var isNpm = isModularize && /\bnpm\b/.test([ui.buildPath, ui.urlParams.build]);
|
||||
|
||||
/** Detect if running in PhantomJS. */
|
||||
var isPhantom = phantom || (typeof callPhantom == 'function');
|
||||
var isPhantom = phantom || (typeof callPhantom === 'function');
|
||||
|
||||
/** Detect if lodash is in strict mode. */
|
||||
var isStrict = ui.isStrict;
|
||||
@@ -459,7 +459,7 @@ function toArgs(array) {
|
||||
// Add bizarro values.
|
||||
(function() {
|
||||
return; // fixme
|
||||
if (document || (typeof require != 'function')) {
|
||||
if (document || (typeof require !== 'function')) {
|
||||
return;
|
||||
}
|
||||
var nativeString = fnToString.call(toString),
|
||||
|
||||
@@ -42,17 +42,17 @@ const freeParseInt = parseInt
|
||||
* // => 3.2
|
||||
*/
|
||||
function toNumber(value) {
|
||||
if (typeof value == 'number') {
|
||||
if (typeof value === 'number') {
|
||||
return value
|
||||
}
|
||||
if (isSymbol(value)) {
|
||||
return NAN
|
||||
}
|
||||
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
|
||||
}
|
||||
if (typeof value != 'string') {
|
||||
if (typeof value !== 'string') {
|
||||
return value === 0 ? value : +value
|
||||
}
|
||||
value = value.replace(reTrim, '')
|
||||
|
||||
@@ -27,7 +27,7 @@ function toString(value) {
|
||||
return ''
|
||||
}
|
||||
// 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)) {
|
||||
|
||||
@@ -43,7 +43,7 @@ function transform(object, iteratee, accumulator) {
|
||||
accumulator = isArr ? new Ctor : []
|
||||
}
|
||||
else if (isObject(object)) {
|
||||
accumulator = typeof Ctor == 'function'
|
||||
accumulator = typeof Ctor === 'function'
|
||||
? Object.create(Object.getPrototypeOf(object))
|
||||
: {}
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ import last from './last.js'
|
||||
*/
|
||||
function unionWith(...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)
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ import baseUniq from './.internal/baseUniq.js'
|
||||
* // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]
|
||||
*/
|
||||
function uniqWith(array, comparator) {
|
||||
comparator = typeof comparator == 'function' ? comparator : undefined
|
||||
comparator = typeof comparator === 'function' ? comparator : undefined
|
||||
return (array != null && array.length)
|
||||
? baseUniq(array, undefined, comparator)
|
||||
: []
|
||||
|
||||
@@ -23,7 +23,7 @@ import baseUpdate from './.internal/baseUpdate.js'
|
||||
* // => { '0': { '1': 'a' } }
|
||||
*/
|
||||
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)
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ import last from './last.js'
|
||||
*/
|
||||
function xorWith(...arrays) {
|
||||
let comparator = last(arrays)
|
||||
comparator = typeof comparator == 'function' ? comparator : undefined
|
||||
comparator = typeof comparator === 'function' ? comparator : undefined
|
||||
return baseXor(arrays.filter(isArrayLikeObject), undefined, comparator)
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ import unzipWith from './unzipWith.js'
|
||||
function zipWith(...arrays) {
|
||||
const length = arrays.length
|
||||
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)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user