iterator-helper-throws-on-invalid-iterator.js 421 B

123456789101112
  1. 'use strict';
  2. // Should throw an error on invalid iterator
  3. // https://issues.chromium.org/issues/336839115
  4. module.exports = function (methodName, argument) {
  5. // eslint-disable-next-line es/no-iterator -- required for testing
  6. var method = typeof Iterator == 'function' && Iterator.prototype[methodName];
  7. if (method) try {
  8. method.call({ next: null }, argument).next();
  9. } catch (error) {
  10. return true;
  11. }
  12. };