Last change
on this file since 1ad8e64 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
1009 bytes
|
Line | |
---|
1 | var TO_STRING_TAG_SUPPORT = require('../internals/to-string-tag-support');
|
---|
2 | var classofRaw = require('../internals/classof-raw');
|
---|
3 | var wellKnownSymbol = require('../internals/well-known-symbol');
|
---|
4 |
|
---|
5 | var TO_STRING_TAG = wellKnownSymbol('toStringTag');
|
---|
6 | // ES3 wrong here
|
---|
7 | var CORRECT_ARGUMENTS = classofRaw(function () { return arguments; }()) == 'Arguments';
|
---|
8 |
|
---|
9 | // fallback for IE11 Script Access Denied error
|
---|
10 | var tryGet = function (it, key) {
|
---|
11 | try {
|
---|
12 | return it[key];
|
---|
13 | } catch (error) { /* empty */ }
|
---|
14 | };
|
---|
15 |
|
---|
16 | // getting tag from ES6+ `Object.prototype.toString`
|
---|
17 | module.exports = TO_STRING_TAG_SUPPORT ? classofRaw : function (it) {
|
---|
18 | var O, tag, result;
|
---|
19 | return it === undefined ? 'Undefined' : it === null ? 'Null'
|
---|
20 | // @@toStringTag case
|
---|
21 | : typeof (tag = tryGet(O = Object(it), TO_STRING_TAG)) == 'string' ? tag
|
---|
22 | // builtinTag case
|
---|
23 | : CORRECT_ARGUMENTS ? classofRaw(O)
|
---|
24 | // ES3 arguments fallback
|
---|
25 | : (result = classofRaw(O)) == 'Object' && typeof O.callee == 'function' ? 'Arguments' : result;
|
---|
26 | };
|
---|
Note:
See
TracBrowser
for help on using the repository browser.