|
Last change
on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 13 days ago |
|
Fix frontend appearance
|
-
Property mode
set to
100644
|
|
File size:
896 bytes
|
| Line | |
|---|
| 1 | 'use strict';
|
|---|
| 2 |
|
|---|
| 3 | var $TypeError = require('es-errors/type');
|
|---|
| 4 | var isObject = require('es-object-atoms/isObject');
|
|---|
| 5 |
|
|---|
| 6 | var Call = require('./Call');
|
|---|
| 7 |
|
|---|
| 8 | var isIteratorRecord = require('../helpers/records/iterator-record-2023');
|
|---|
| 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 (!isObject(result)) {
|
|---|
| 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.