IteratorNext.js 440 B

12345678910111213141516
  1. 'use strict';
  2. var $TypeError = require('es-errors/type');
  3. var Invoke = require('./Invoke');
  4. var Type = require('./Type');
  5. // https://262.ecma-international.org/6.0/#sec-iteratornext
  6. module.exports = function IteratorNext(iterator, value) {
  7. var result = Invoke(iterator, 'next', arguments.length < 2 ? [] : [value]);
  8. if (Type(result) !== 'Object') {
  9. throw new $TypeError('iterator next must return an object');
  10. }
  11. return result;
  12. };