source: imaps-frontend/node_modules/es-abstract/2024/IteratorNext.js@ d565449

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
Line 
1'use strict';
2
3var $TypeError = require('es-errors/type');
4
5var Call = require('./Call');
6var Type = require('./Type');
7
8var isIteratorRecord = require('../helpers/records/iterator-record');
9
10// https://262.ecma-international.org/14.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 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.