main
Last change
on this file was 0c6b92a, checked in by stefan toskovski <stefantoska84@…>, 5 weeks ago |
Pred finalna verzija
|
-
Property mode
set to
100644
|
File size:
1.1 KB
|
Rev | Line | |
---|
[0c6b92a] | 1 | 'use strict';
|
---|
| 2 |
|
---|
| 3 | var $TypeError = require('es-errors/type');
|
---|
| 4 |
|
---|
| 5 | var CompletionRecord = require('es-abstract/2024/CompletionRecord');
|
---|
| 6 | var IteratorClose = require('es-abstract/2024/IteratorClose');
|
---|
| 7 | var ThrowCompletion = require('es-abstract/2024/ThrowCompletion');
|
---|
| 8 |
|
---|
| 9 | var IsArray = require('es-abstract/helpers/IsArray');
|
---|
| 10 | var every = require('es-abstract/helpers/every');
|
---|
| 11 |
|
---|
| 12 | var isIteratorRecord = require('es-abstract/helpers/records/iterator-record');
|
---|
| 13 |
|
---|
| 14 | // https://tc39.es/proposal-joint-iteration/#sec-closeall
|
---|
| 15 |
|
---|
| 16 | module.exports = function IteratorCloseAll(iters, completion) {
|
---|
| 17 | if (!IsArray(iters) || !every(iters, isIteratorRecord)) {
|
---|
| 18 | throw new $TypeError('Assertion failed: `iters` must be a List of IteratorRecords');
|
---|
| 19 | }
|
---|
| 20 | if (!(completion instanceof CompletionRecord)) {
|
---|
| 21 | throw new $TypeError('Assertion failed: `completion` must be a Completion Record');
|
---|
| 22 | }
|
---|
| 23 |
|
---|
| 24 | for (var i = iters.length - 1; i >= 0; i -= 1) { // step 1
|
---|
| 25 | try {
|
---|
| 26 | IteratorClose(iters[i], completion); // step 1.a
|
---|
| 27 | } catch (e) {
|
---|
| 28 | // eslint-disable-next-line no-param-reassign
|
---|
| 29 | completion = ThrowCompletion(e); // step 1.a
|
---|
| 30 | }
|
---|
| 31 | }
|
---|
| 32 |
|
---|
| 33 | return completion['?'](); // step 2
|
---|
| 34 | };
|
---|
Note:
See
TracBrowser
for help on using the repository browser.