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