UNPKG

1.14 kBJavaScriptView Raw
1import Symbol from './_Symbol.js';
2
3/** Used for built-in method references. */
4var objectProto = Object.prototype;
5
6/** Used to check objects for own properties. */
7var hasOwnProperty = objectProto.hasOwnProperty;
8
9/**
10 * Used to resolve the
11 * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
12 * of values.
13 */
14var nativeObjectToString = objectProto.toString;
15
16/** Built-in value references. */
17var symToStringTag = Symbol ? Symbol.toStringTag : undefined;
18
19/**
20 * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
21 *
22 * @private
23 * @param {*} value The value to query.
24 * @returns {string} Returns the raw `toStringTag`.
25 */
26function getRawTag(value) {
27 var isOwn = hasOwnProperty.call(value, symToStringTag),
28 tag = value[symToStringTag];
29
30 try {
31 value[symToStringTag] = undefined;
32 var unmasked = true;
33 } catch (e) {}
34
35 var result = nativeObjectToString.call(value);
36 if (unmasked) {
37 if (isOwn) {
38 value[symToStringTag] = tag;
39 } else {
40 delete value[symToStringTag];
41 }
42 }
43 return result;
44}
45
46export default getRawTag;