source: imaps-frontend/node_modules/es-abstract/2023/IteratorToList.js

main
Last change on this file was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago

Update repo after prototype presentation

  • Property mode set to 100644
File size: 882 bytes
RevLine 
[d565449]1'use strict';
2
3var $TypeError = require('es-errors/type');
4
5var callBound = require('call-bind/callBound');
6
7var $arrayPush = callBound('Array.prototype.push');
8
9var IteratorStep = require('./IteratorStep');
10var IteratorValue = require('./IteratorValue');
11
12var isIteratorRecord = require('../helpers/records/iterator-record');
13
14// https://262.ecma-international.org/14.0/#sec-iteratortolist
15
16module.exports = function IteratorToList(iteratorRecord) {
17 if (!isIteratorRecord(iteratorRecord)) {
18 throw new $TypeError('Assertion failed: `iteratorRecord` must be an Iterator Record'); // step 1
19 }
20
21 var values = []; // step 1
22 var next = true; // step 2
23 while (next) { // step 3
24 next = IteratorStep(iteratorRecord); // step 3.a
25 if (next) {
26 var nextValue = IteratorValue(next); // step 3.b.i
27 $arrayPush(values, nextValue); // step 3.b.ii
28 }
29 }
30 return values; // step 4
31};
Note: See TracBrowser for help on using the repository browser.