source: imaps-frontend/node_modules/es-abstract/2024/IteratorStepValue.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: 1.2 KB
Line 
1'use strict';
2
3var $TypeError = require('es-errors/type');
4
5var Get = require('./Get');
6var IteratorComplete = require('./IteratorComplete');
7var IteratorNext = require('./IteratorNext');
8
9var isIteratorRecord = require('../helpers/records/iterator-record');
10
11// https://262.ecma-international.org/15.0/#sec-iteratorstepvalue
12
13module.exports = function IteratorStepValue(iteratorRecord) {
14 if (!isIteratorRecord(iteratorRecord)) {
15 throw new $TypeError('Assertion failed: `iteratorRecord` must be an Iterator Record');
16 }
17 /* eslint no-param-reassign: 0 */
18
19 var result;
20 try {
21 result = IteratorNext(iteratorRecord); // step 1
22 } catch (e) { // step 2
23 iteratorRecord['[[Done]]'] = true; // step 2.a
24 throw e; // step 2.b
25 }
26
27 var done;
28 try {
29 done = IteratorComplete(result); // step 4
30 } catch (e) { // step 5
31 iteratorRecord['[[Done]]'] = true; // step 5.a
32 throw e; // step 5.b
33 }
34
35 if (done) { // step 7
36 iteratorRecord['[[Done]]'] = true; // step 7.a
37 return 'DONE'; // step 7.b
38 }
39
40 var value;
41 try {
42 value = Get(result, 'value'); // step 8
43 } catch (e) { // step 9
44 iteratorRecord['[[Done]]'] = true; // step 9.a
45 throw e; // step 10
46 }
47
48 return value; // step 10
49};
Note: See TracBrowser for help on using the repository browser.