mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-06 09:47:48 +00:00
Remove getRawTag and objectToString.
This commit is contained in:
@@ -1,12 +1,7 @@
|
||||
import getRawTag from './getRawTag.js'
|
||||
import objectToString from './objectToString.js'
|
||||
|
||||
/** `Object#toString` result references. */
|
||||
const nullTag = '[object Null]'
|
||||
const undefinedTag = '[object Undefined]'
|
||||
|
||||
/** Built-in value references. */
|
||||
const symToStringTag = Symbol ? Symbol.toStringTag : undefined
|
||||
const objectProto = Object.prototype
|
||||
const hasOwnProperty = objectProto.hasOwnProperty
|
||||
const toString = objectProto.toString
|
||||
const symToStringTag = typeof Symbol != 'undefined' ? Symbol.toStringTag : undefined
|
||||
|
||||
/**
|
||||
* The base implementation of `getTag` without fallbacks for buggy environments.
|
||||
@@ -17,11 +12,28 @@ const symToStringTag = Symbol ? Symbol.toStringTag : undefined
|
||||
*/
|
||||
function baseGetTag(value) {
|
||||
if (value == null) {
|
||||
return value === undefined ? undefinedTag : nullTag
|
||||
return value === undefined ? '[object Undefined]' : '[object Null]'
|
||||
}
|
||||
return (symToStringTag && symToStringTag in Object(value))
|
||||
? getRawTag(value)
|
||||
: objectToString(value)
|
||||
if (!(symToStringTag && symToStringTag in Object(value))) {
|
||||
return toString.call(value)
|
||||
}
|
||||
const isOwn = hasOwnProperty.call(value, symToStringTag)
|
||||
const tag = value[symToStringTag]
|
||||
let unmasked = false
|
||||
try {
|
||||
value[symToStringTag] = undefined
|
||||
unmasked = true
|
||||
} catch (e) {}
|
||||
|
||||
const result = toString.call(value)
|
||||
if (unmasked) {
|
||||
if (isOwn) {
|
||||
value[symToStringTag] = tag
|
||||
} else {
|
||||
delete value[symToStringTag]
|
||||
}
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
export default baseGetTag
|
||||
|
||||
Reference in New Issue
Block a user