main
Last change
on this file since d565449 was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago |
Update repo after prototype presentation
|
-
Property mode
set to
100644
|
File size:
877 bytes
|
Rev | Line | |
---|
[d565449] | 1 | 'use strict';
|
---|
| 2 |
|
---|
| 3 | var $TypeError = require('es-errors/type');
|
---|
| 4 |
|
---|
| 5 | var Call = require('./Call');
|
---|
| 6 | var Type = require('./Type');
|
---|
| 7 |
|
---|
| 8 | var isIteratorRecord = require('../helpers/records/iterator-record');
|
---|
| 9 |
|
---|
| 10 | // https://262.ecma-international.org/14.0/#sec-iteratornext
|
---|
| 11 |
|
---|
| 12 | module.exports = function IteratorNext(iteratorRecord) {
|
---|
| 13 | if (!isIteratorRecord(iteratorRecord)) {
|
---|
| 14 | throw new $TypeError('Assertion failed: `iteratorRecord` must be an Iterator Record'); // step 1
|
---|
| 15 | }
|
---|
| 16 |
|
---|
| 17 | var result;
|
---|
| 18 | if (arguments.length < 2) { // step 1
|
---|
| 19 | result = Call(iteratorRecord['[[NextMethod]]'], iteratorRecord['[[Iterator]]']); // step 1.a
|
---|
| 20 | } else { // step 2
|
---|
| 21 | result = Call(iteratorRecord['[[NextMethod]]'], iteratorRecord['[[Iterator]]'], [arguments[1]]); // step 2.a
|
---|
| 22 | }
|
---|
| 23 |
|
---|
| 24 | if (Type(result) !== 'Object') {
|
---|
| 25 | throw new $TypeError('iterator next must return an object'); // step 3
|
---|
| 26 | }
|
---|
| 27 | return result; // step 4
|
---|
| 28 | };
|
---|
Note:
See
TracBrowser
for help on using the repository browser.