mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-06 01:47:48 +00:00
Move internal modules to “internal” folder.
This commit is contained in:
45
.internal/getRawTag.js
Normal file
45
.internal/getRawTag.js
Normal file
@@ -0,0 +1,45 @@
|
||||
/** Used for built-in method references. */
|
||||
const objectProto = Object.prototype;
|
||||
|
||||
/** Used to check objects for own properties. */
|
||||
const hasOwnProperty = objectProto.hasOwnProperty;
|
||||
|
||||
/**
|
||||
* Used to resolve the
|
||||
* [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
|
||||
* of values.
|
||||
*/
|
||||
const nativeObjectToString = objectProto.toString;
|
||||
|
||||
/** Built-in value references. */
|
||||
const symToStringTag = Symbol ? Symbol.toStringTag : undefined;
|
||||
|
||||
/**
|
||||
* A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
|
||||
*
|
||||
* @private
|
||||
* @param {*} value The value to query.
|
||||
* @returns {string} Returns the raw `toStringTag`.
|
||||
*/
|
||||
function getRawTag(value) {
|
||||
const isOwn = hasOwnProperty.call(value, symToStringTag);
|
||||
const tag = value[symToStringTag];
|
||||
let unmasked = false;
|
||||
|
||||
try {
|
||||
value[symToStringTag] = undefined;
|
||||
unmasked = true;
|
||||
} catch (e) {}
|
||||
|
||||
const result = nativeObjectToString.call(value);
|
||||
if (unmasked) {
|
||||
if (isOwn) {
|
||||
value[symToStringTag] = tag;
|
||||
} else {
|
||||
delete value[symToStringTag];
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
export default getRawTag;
|
||||
Reference in New Issue
Block a user