|
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:
996 bytes
|
| Line | |
|---|
| 1 | 'use strict';
|
|---|
| 2 |
|
|---|
| 3 | var $TypeError = require('es-errors/type');
|
|---|
| 4 |
|
|---|
| 5 | var IteratorComplete = require('./IteratorComplete');
|
|---|
| 6 | var IteratorNext = require('./IteratorNext');
|
|---|
| 7 |
|
|---|
| 8 | var isIteratorRecord = require('../helpers/records/iterator-record');
|
|---|
| 9 |
|
|---|
| 10 | // https://262.ecma-international.org/16.0/#sec-iteratorstep
|
|---|
| 11 |
|
|---|
| 12 | module.exports = function IteratorStep(iteratorRecord) {
|
|---|
| 13 | if (!isIteratorRecord(iteratorRecord)) {
|
|---|
| 14 | throw new $TypeError('Assertion failed: `iteratorRecord` must be an Iterator Record'); // step 1
|
|---|
| 15 | }
|
|---|
| 16 |
|
|---|
| 17 | var result = IteratorNext(iteratorRecord); // step 1
|
|---|
| 18 | try {
|
|---|
| 19 | var done = IteratorComplete(result); // step 2
|
|---|
| 20 | } catch (e) { // step 3
|
|---|
| 21 | // eslint-disable-next-line no-param-reassign
|
|---|
| 22 | iteratorRecord['[[Done]]'] = true; // step 3.a
|
|---|
| 23 | throw e; // step 3.b
|
|---|
| 24 |
|
|---|
| 25 | }
|
|---|
| 26 |
|
|---|
| 27 | if (done) { // step 5
|
|---|
| 28 | // eslint-disable-next-line no-param-reassign
|
|---|
| 29 | iteratorRecord['[[Done]]'] = true; // step 5.a
|
|---|
| 30 | return false; // step 5.b. should be `~done~` but `false` is more convenient here.
|
|---|
| 31 | }
|
|---|
| 32 |
|
|---|
| 33 | return result; // steps 6
|
|---|
| 34 | };
|
|---|
| 35 |
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.