mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-01-29 06:27:49 +00:00
Assume Symbol is always defined (#4111)
This commit is contained in:
committed by
John-David Dalton
parent
4c55ea7068
commit
6cb1f71adf
@@ -1,7 +1,7 @@
|
||||
const objectProto = Object.prototype
|
||||
const hasOwnProperty = objectProto.hasOwnProperty
|
||||
const toString = objectProto.toString
|
||||
const symToStringTag = typeof Symbol != 'undefined' ? Symbol.toStringTag : undefined
|
||||
const symToStringTag = Symbol.toStringTag
|
||||
|
||||
/**
|
||||
* The base implementation of `getTag` without fallbacks for buggy environments.
|
||||
@@ -14,7 +14,7 @@ function baseGetTag(value) {
|
||||
if (value == null) {
|
||||
return value === undefined ? '[object Undefined]' : '[object Null]'
|
||||
}
|
||||
if (!(symToStringTag && symToStringTag in Object(value))) {
|
||||
if (!(symToStringTag in Object(value))) {
|
||||
return toString.call(value)
|
||||
}
|
||||
const isOwn = hasOwnProperty.call(value, symToStringTag)
|
||||
|
||||
@@ -4,8 +4,7 @@ import isSymbol from '../isSymbol.js'
|
||||
const INFINITY = 1 / 0
|
||||
|
||||
/** Used to convert symbols to primitives and strings. */
|
||||
const symbolProto = Symbol ? Symbol.prototype : undefined
|
||||
const symbolToString = symbolProto ? symbolProto.toString : undefined
|
||||
const symbolToString = Symbol.prototype.toString
|
||||
|
||||
/**
|
||||
* The base implementation of `toString` which doesn't convert nullish
|
||||
|
||||
@@ -9,7 +9,7 @@ const symbolValueOf = Symbol.prototype.valueOf
|
||||
* @returns {Object} Returns the cloned symbol object.
|
||||
*/
|
||||
function cloneSymbol(symbol) {
|
||||
return symbolValueOf ? Object(symbolValueOf.call(symbol)) : {}
|
||||
return Object(symbolValueOf.call(symbol))
|
||||
}
|
||||
|
||||
export default cloneSymbol
|
||||
|
||||
@@ -22,8 +22,7 @@ const arrayBufferTag = '[object ArrayBuffer]'
|
||||
const dataViewTag = '[object DataView]'
|
||||
|
||||
/** Used to convert symbols to primitives and strings. */
|
||||
const symbolProto = Symbol ? Symbol.prototype : undefined
|
||||
const symbolValueOf = symbolProto ? symbolProto.valueOf : undefined
|
||||
const symbolValueOf = Symbol.prototype.valueOf
|
||||
|
||||
/**
|
||||
* A specialized version of `baseIsEqualDeep` for comparing objects of
|
||||
|
||||
@@ -12,7 +12,7 @@ const spreadableSymbol = Symbol.isConcatSpreadable
|
||||
*/
|
||||
function isFlattenable(value) {
|
||||
return Array.isArray(value) || isArguments(value) ||
|
||||
!!(spreadableSymbol && value && value[spreadableSymbol])
|
||||
!!(value && value[spreadableSymbol])
|
||||
}
|
||||
|
||||
export default isFlattenable
|
||||
|
||||
@@ -13,7 +13,7 @@ const mapTag = '[object Map]'
|
||||
const setTag = '[object Set]'
|
||||
|
||||
/** Built-in value references. */
|
||||
const symIterator = Symbol ? Symbol.iterator : undefined
|
||||
const symIterator = Symbol.iterator
|
||||
|
||||
/**
|
||||
* Converts `value` to an array.
|
||||
|
||||
@@ -5,8 +5,7 @@ import isSymbol from './isSymbol.js'
|
||||
const INFINITY = 1 / 0
|
||||
|
||||
/** Used to convert symbols to primitives and strings. */
|
||||
const symbolProto = Symbol ? Symbol.prototype : undefined
|
||||
const symbolToString = symbolProto ? symbolProto.toString : undefined
|
||||
const symbolToString = Symbol.prototype.toString
|
||||
|
||||
/**
|
||||
* Converts `value` to a string. An empty string is returned for `null`
|
||||
|
||||
Reference in New Issue
Block a user