main
Last change
on this file was 79a0317, checked in by stefan toskovski <stefantoska84@…>, 2 weeks ago |
F4 Finalna Verzija
|
-
Property mode
set to
100644
|
File size:
1.1 KB
|
Rev | Line | |
---|
[79a0317] | 1 | 'use strict';
|
---|
| 2 | var TO_STRING_TAG_SUPPORT = require('../internals/to-string-tag-support');
|
---|
| 3 | var isCallable = require('../internals/is-callable');
|
---|
| 4 | var classofRaw = require('../internals/classof-raw');
|
---|
| 5 | var wellKnownSymbol = require('../internals/well-known-symbol');
|
---|
| 6 |
|
---|
| 7 | var TO_STRING_TAG = wellKnownSymbol('toStringTag');
|
---|
| 8 | var $Object = Object;
|
---|
| 9 |
|
---|
| 10 | // ES3 wrong here
|
---|
| 11 | var CORRECT_ARGUMENTS = classofRaw(function () { return arguments; }()) === 'Arguments';
|
---|
| 12 |
|
---|
| 13 | // fallback for IE11 Script Access Denied error
|
---|
| 14 | var tryGet = function (it, key) {
|
---|
| 15 | try {
|
---|
| 16 | return it[key];
|
---|
| 17 | } catch (error) { /* empty */ }
|
---|
| 18 | };
|
---|
| 19 |
|
---|
| 20 | // getting tag from ES6+ `Object.prototype.toString`
|
---|
| 21 | module.exports = TO_STRING_TAG_SUPPORT ? classofRaw : function (it) {
|
---|
| 22 | var O, tag, result;
|
---|
| 23 | return it === undefined ? 'Undefined' : it === null ? 'Null'
|
---|
| 24 | // @@toStringTag case
|
---|
| 25 | : typeof (tag = tryGet(O = $Object(it), TO_STRING_TAG)) == 'string' ? tag
|
---|
| 26 | // builtinTag case
|
---|
| 27 | : CORRECT_ARGUMENTS ? classofRaw(O)
|
---|
| 28 | // ES3 arguments fallback
|
---|
| 29 | : (result = classofRaw(O)) === 'Object' && isCallable(O.callee) ? 'Arguments' : result;
|
---|
| 30 | };
|
---|
Note:
See
TracBrowser
for help on using the repository browser.