MES手机端
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.
 
 
 
 

42 lines
1.1 KiB

  1. 'use strict';
  2. var wellKnownSymbol = require('../internals/well-known-symbol');
  3. var ITERATOR = wellKnownSymbol('iterator');
  4. var SAFE_CLOSING = false;
  5. try {
  6. var called = 0;
  7. var iteratorWithReturn = {
  8. next: function () {
  9. return { done: !!called++ };
  10. },
  11. 'return': function () {
  12. SAFE_CLOSING = true;
  13. }
  14. };
  15. iteratorWithReturn[ITERATOR] = function () {
  16. return this;
  17. };
  18. // eslint-disable-next-line es/no-array-from, no-throw-literal -- required for testing
  19. Array.from(iteratorWithReturn, function () { throw 2; });
  20. } catch (error) { /* empty */ }
  21. module.exports = function (exec, SKIP_CLOSING) {
  22. try {
  23. if (!SKIP_CLOSING && !SAFE_CLOSING) return false;
  24. } catch (error) { return false; } // workaround of old WebKit + `eval` bug
  25. var ITERATION_SUPPORT = false;
  26. try {
  27. var object = {};
  28. object[ITERATOR] = function () {
  29. return {
  30. next: function () {
  31. return { done: ITERATION_SUPPORT = true };
  32. }
  33. };
  34. };
  35. exec(object);
  36. } catch (error) { /* empty */ }
  37. return ITERATION_SUPPORT;
  38. };