_classof.js 718 B

1234567891011121314151617181920212223
  1. // getting tag from 19.1.3.6 Object.prototype.toString()
  2. var cof = require('./_cof');
  3. var TAG = require('./_wks')('toStringTag');
  4. // ES3 wrong here
  5. var ARG = cof(function () { return arguments; }()) == 'Arguments';
  6. // fallback for IE11 Script Access Denied error
  7. var tryGet = function (it, key) {
  8. try {
  9. return it[key];
  10. } catch (e) { /* empty */ }
  11. };
  12. module.exports = function (it) {
  13. var O, T, B;
  14. return it === undefined ? 'Undefined' : it === null ? 'Null'
  15. // @@toStringTag case
  16. : typeof (T = tryGet(O = Object(it), TAG)) == 'string' ? T
  17. // builtinTag case
  18. : ARG ? cof(O)
  19. // ES3 arguments fallback
  20. : (B = cof(O)) == 'Object' && typeof O.callee == 'function' ? 'Arguments' : B;
  21. };