Assume Symbol is always defined (#4111)

This commit is contained in:
Luiz Américo
2018-12-10 21:28:20 -03:00
committed by John-David Dalton
parent 4c55ea7068
commit 6cb1f71adf
7 changed files with 8 additions and 11 deletions

View File

@@ -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)

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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.

View File

@@ -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`