IteratorNext.js 488 B

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