source: frontend/node_modules/es-abstract/2025/IteratorNext.js

Last change on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 12 days ago

Fix frontend appearance

  • Property mode set to 100644
File size: 1.1 KB
Line 
1'use strict';
2
3var $TypeError = require('es-errors/type');
4var isObject = require('es-object-atoms/isObject');
5
6var Call = require('./Call');
7
8var isIteratorRecord = require('../helpers/records/iterator-record');
9
10// https://262.ecma-international.org/16.0/#sec-iteratornext
11
12module.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 try {
19 if (arguments.length < 2) { // step 1
20 result = Call(iteratorRecord['[[NextMethod]]'], iteratorRecord['[[Iterator]]']); // step 1.a
21 } else { // step 2
22 result = Call(iteratorRecord['[[NextMethod]]'], iteratorRecord['[[Iterator]]'], [arguments[1]]); // step 2.a
23 }
24 } catch (e) { // step 3
25 // eslint-disable-next-line no-param-reassign
26 iteratorRecord['[[Done]]'] = true; // step 3.a
27 throw e; // step 3.b
28 }
29
30 if (!isObject(result)) { // step 5
31 // eslint-disable-next-line no-param-reassign
32 iteratorRecord['[[Done]]'] = true; // step 5.a
33 throw new $TypeError('iterator next must return an object'); // step 5.b
34 }
35 return result; // step 6
36};
Note: See TracBrowser for help on using the repository browser.