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.

31 lines
949 B

4 years ago
  1. 'use strict';
  2. var hasToStringTag = typeof Symbol === 'function' && typeof Symbol.toStringTag === 'symbol';
  3. var toStr = Object.prototype.toString;
  4. var isStandardArguments = function isArguments(value) {
  5. if (hasToStringTag && value && typeof value === 'object' && Symbol.toStringTag in value) {
  6. return false;
  7. }
  8. return toStr.call(value) === '[object Arguments]';
  9. };
  10. var isLegacyArguments = function isArguments(value) {
  11. if (isStandardArguments(value)) {
  12. return true;
  13. }
  14. return value !== null &&
  15. typeof value === 'object' &&
  16. typeof value.length === 'number' &&
  17. value.length >= 0 &&
  18. toStr.call(value) !== '[object Array]' &&
  19. toStr.call(value.callee) === '[object Function]';
  20. };
  21. var supportsStandardArguments = (function () {
  22. return isStandardArguments(arguments);
  23. }());
  24. isStandardArguments.isLegacyArguments = isLegacyArguments; // for tests
  25. module.exports = supportsStandardArguments ? isStandardArguments : isLegacyArguments;