12345678910111213141516171819202122232425262728 |
- 'use strict';
- var $TypeError = require('es-errors/type');
- var Call = require('./Call');
- var Type = require('./Type');
- var isIteratorRecord = require('../helpers/records/iterator-record');
- module.exports = function IteratorNext(iteratorRecord) {
- if (!isIteratorRecord(iteratorRecord)) {
- throw new $TypeError('Assertion failed: `iteratorRecord` must be an Iterator Record');
- }
- var result;
- if (arguments.length < 2) {
- result = Call(iteratorRecord['[[NextMethod]]'], iteratorRecord['[[Iterator]]']);
- } else {
- result = Call(iteratorRecord['[[NextMethod]]'], iteratorRecord['[[Iterator]]'], [arguments[1]]);
- }
- if (Type(result) !== 'Object') {
- throw new $TypeError('iterator next must return an object');
- }
- return result;
- };
|