Node-Red configuration
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

classof.js 1.1KB

123456789101112131415161718192021222324252627282930
  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. var TO_STRING_TAG = wellKnownSymbol('toStringTag');
  7. var $Object = Object;
  8. // ES3 wrong here
  9. var CORRECT_ARGUMENTS = classofRaw(function () { return arguments; }()) === 'Arguments';
  10. // fallback for IE11 Script Access Denied error
  11. var tryGet = function (it, key) {
  12. try {
  13. return it[key];
  14. } catch (error) { /* empty */ }
  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' && isCallable(O.callee) ? 'Arguments' : result;
  26. };