@@ -350,9 +350,8 @@ <h1>Iterator.prototype.map ( _mapper_ )</h1>
350
350
1. Let _closure_ be a new Abstract Closure with no parameters that captures _iterated_ and _mapper_ and performs the following steps when called:
351
351
1. Let _counter_ be 0.
352
352
1. Repeat,
353
- 1. Let _next_ be ? IteratorStep(_iterated_ ).
354
- 1. If _next_ is *false* , return *undefined* .
355
- 1. Let _value_ be ? IteratorValue(_next_ ).
353
+ 1. Let _value_ be ? IteratorStepValue(_iterated_ ).
354
+ 1. If _value_ is ~done~ , return *undefined* .
356
355
1. Let _mapped_ be Completion(Call(_mapper_ , *undefined* , « _value_ , 𝔽(_counter_ ) »)).
357
356
1. IfAbruptCloseIterator(_mapped_ , _iterated_ ).
358
357
1. Let _completion_ be Completion(Yield(_mapped_ )).
@@ -375,9 +374,8 @@ <h1>Iterator.prototype.filter ( _predicate_ )</h1>
375
374
1. Let _closure_ be a new Abstract Closure with no parameters that captures _iterated_ and _predicate_ and performs the following steps when called:
376
375
1. Let _counter_ be 0.
377
376
1. Repeat,
378
- 1. Let _next_ be ? IteratorStep(_iterated_ ).
379
- 1. If _next_ is *false* , return *undefined* .
380
- 1. Let _value_ be ? IteratorValue(_next_ ).
377
+ 1. Let _value_ be ? IteratorStepValue(_iterated_ ).
378
+ 1. If _value_ is ~done~ , return *undefined* .
381
379
1. Let _selected_ be Completion(Call(_predicate_ , *undefined* , « _value_ , 𝔽(_counter_ ) »)).
382
380
1. IfAbruptCloseIterator(_selected_ , _iterated_ ).
383
381
1. If ToBoolean(_selected_ ) is *true* , then
@@ -408,9 +406,9 @@ <h1>Iterator.prototype.take ( _limit_ )</h1>
408
406
1. Return ? IteratorClose(_iterated_ , NormalCompletion(*undefined* )).
409
407
1. If _remaining_ is not +∞, then
410
408
1. Set _remaining_ to _remaining_ - 1.
411
- 1. Let _next_ be ? IteratorStep (_iterated_ ).
412
- 1. If _next_ is *false* , return *undefined* .
413
- 1. Let _completion_ be Completion(Yield(? IteratorValue( _next_ ) )).
409
+ 1. Let _value_ be ? IteratorStepValue (_iterated_ ).
410
+ 1. If _value_ is ~done~ , return *undefined* .
411
+ 1. Let _completion_ be Completion(Yield(_value_ )).
414
412
1. IfAbruptCloseIterator(_completion_ , _iterated_ ).
415
413
1. Let _result_ be CreateIteratorFromClosure(_closure_ , *"Iterator Helper"* , %IteratorHelperPrototype%, « [[UnderlyingIterator]] »).
416
414
1. Set _result_ .[[UnderlyingIterator]] to _iterated_ .
@@ -437,9 +435,9 @@ <h1>Iterator.prototype.drop ( _limit_ )</h1>
437
435
1. Let _next_ be ? IteratorStep(_iterated_ ).
438
436
1. If _next_ is *false* , return *undefined* .
439
437
1. Repeat,
440
- 1. Let _next_ be ? IteratorStep (_iterated_ ).
441
- 1. If _next_ is *false* , return *undefined* .
442
- 1. Let _completion_ be Completion(Yield(? IteratorValue( _next_ ) )).
438
+ 1. Let _value_ be ? IteratorStepValue (_iterated_ ).
439
+ 1. If _value_ is ~done~ , return *undefined* .
440
+ 1. Let _completion_ be Completion(Yield(_value_ )).
443
441
1. IfAbruptCloseIterator(_completion_ , _iterated_ ).
444
442
1. Let _result_ be CreateIteratorFromClosure(_closure_ , *"Iterator Helper"* , %IteratorHelperPrototype%, « [[UnderlyingIterator]] »).
445
443
1. Set _result_ .[[UnderlyingIterator]] to _iterated_ .
@@ -458,22 +456,19 @@ <h1>Iterator.prototype.flatMap ( _mapper_ )</h1>
458
456
1. Let _closure_ be a new Abstract Closure with no parameters that captures _iterated_ and _mapper_ and performs the following steps when called:
459
457
1. Let _counter_ be 0.
460
458
1. Repeat,
461
- 1. Let _next_ be ? IteratorStep(_iterated_ ).
462
- 1. If _next_ is *false* , return *undefined* .
463
- 1. Let _value_ be ? IteratorValue(_next_ ).
459
+ 1. Let _value_ be ? IteratorStepValue(_iterated_ ).
460
+ 1. If _value_ is ~done~ , return *undefined* .
464
461
1. Let _mapped_ be Completion(Call(_mapper_ , *undefined* , « _value_ , 𝔽(_counter_ ) »)).
465
462
1. IfAbruptCloseIterator(_mapped_ , _iterated_ ).
466
463
1. Let _innerIterator_ be Completion(GetIteratorFlattenable(_mapped_ , ~reject-strings~ )).
467
464
1. IfAbruptCloseIterator(_innerIterator_ , _iterated_ ).
468
465
1. Let _innerAlive_ be *true* .
469
466
1. Repeat, while _innerAlive_ is *true* ,
470
- 1. Let _innerNext_ be Completion(IteratorStep (_innerIterator_ )).
471
- 1. IfAbruptCloseIterator(_innerNext_ , _iterated_ ).
472
- 1. If _innerNext_ is *false* , then
467
+ 1. Let _innerValue_ be Completion(IteratorStepValue (_innerIterator_ )).
468
+ 1. IfAbruptCloseIterator(_innerValue_ , _iterated_ ).
469
+ 1. If _innerValue_ is ~done~ , then
473
470
1. Set _innerAlive_ to *false* .
474
471
1. Else,
475
- 1. Let _innerValue_ be Completion(IteratorValue(_innerNext_ )).
476
- 1. IfAbruptCloseIterator(_innerValue_ , _iterated_ ).
477
472
1. Let _completion_ be Completion(Yield(_innerValue_ )).
478
473
1. If _completion_ is an abrupt completion, then
479
474
1. Let _backupCompletion_ be Completion(IteratorClose(_innerIterator_ , _completion_ )).
@@ -495,17 +490,15 @@ <h1>Iterator.prototype.reduce ( _reducer_ [ , _initialValue_ ] )</h1>
495
490
1. If IsCallable(_reducer_ ) is *false* , throw a *TypeError* exception.
496
491
1. Let _iterated_ be ? GetIteratorDirect(_O_ ).
497
492
1. If _initialValue_ is not present, then
498
- 1. Let _next_ be ? IteratorStep(_iterated_ ).
499
- 1. If _next_ is *false* , throw a *TypeError* exception.
500
- 1. Let _accumulator_ be ? IteratorValue(_next_ ).
493
+ 1. Let _accumulator_ be ? IteratorStepValue(_iterated_ ).
494
+ 1. If _accumulator_ is ~done~ , throw a *TypeError* exception.
501
495
1. Let _counter_ be 1.
502
496
1. Else,
503
497
1. Let _accumulator_ be _initialValue_ .
504
498
1. Let _counter_ be 0.
505
499
1. Repeat,
506
- 1. Let _next_ be ? IteratorStep(_iterated_ ).
507
- 1. If _next_ is *false* , return _accumulator_ .
508
- 1. Let _value_ be ? IteratorValue(_next_ ).
500
+ 1. Let _value_ be ? IteratorStepValue(_iterated_ ).
501
+ 1. If _value_ is ~done~ , return _accumulator_ .
509
502
1. Let _result_ be Completion(Call(_reducer_ , *undefined* , « _accumulator_ , _value_ , 𝔽(_counter_ ) »)).
510
503
1. IfAbruptCloseIterator(_result_ , _iterated_ ).
511
504
1. Set _accumulator_ to _result_ .[[Value]].
@@ -522,9 +515,8 @@ <h1>Iterator.prototype.toArray ( )</h1>
522
515
1. Let _iterated_ be ? GetIteratorDirect(_O_ ).
523
516
1. Let _items_ be a new empty List.
524
517
1. Repeat,
525
- 1. Let _next_ be ? IteratorStep(_iterated_ ).
526
- 1. If _next_ is *false* , return CreateArrayFromList(_items_ ).
527
- 1. Let _value_ be ? IteratorValue(_next_ ).
518
+ 1. Let _value_ be ? IteratorStepValue(_iterated_ ).
519
+ 1. If _value_ is ~done~ , return CreateArrayFromList(_items_ ).
528
520
1. Append _value_ to _items_ .
529
521
</emu-alg >
530
522
</emu-clause >
@@ -539,9 +531,8 @@ <h1>Iterator.prototype.forEach ( _fn_ )</h1>
539
531
1. Let _iterated_ be ? GetIteratorDirect(_O_ ).
540
532
1. Let _counter_ be 0.
541
533
1. Repeat,
542
- 1. Let _next_ be ? IteratorStep(_iterated_ ).
543
- 1. If _next_ is *false* , return *undefined* .
544
- 1. Let _value_ be ? IteratorValue(_next_ ).
534
+ 1. Let _value_ be ? IteratorStepValue(_iterated_ ).
535
+ 1. If _value_ is ~done~ , return *undefined* .
545
536
1. Let _result_ be Completion(Call(_fn_ , *undefined* , « _value_ , 𝔽(_counter_ ) »)).
546
537
1. IfAbruptCloseIterator(_result_ , _iterated_ ).
547
538
1. Set _counter_ to _counter_ + 1.
@@ -558,9 +549,8 @@ <h1>Iterator.prototype.some ( _predicate_ )</h1>
558
549
1. Let _iterated_ be ? GetIteratorDirect(_O_ ).
559
550
1. Let _counter_ be 0.
560
551
1. Repeat,
561
- 1. Let _next_ be ? IteratorStep(_iterated_ ).
562
- 1. If _next_ is *false* , return *false* .
563
- 1. Let _value_ be ? IteratorValue(_next_ ).
552
+ 1. Let _value_ be ? IteratorStepValue(_iterated_ ).
553
+ 1. If _value_ is ~done~ , return *false* .
564
554
1. Let _result_ be Completion(Call(_predicate_ , *undefined* , « _value_ , 𝔽(_counter_ ) »)).
565
555
1. IfAbruptCloseIterator(_result_ , _iterated_ ).
566
556
1. If ToBoolean(_result_ ) is *true* , return ? IteratorClose(_iterated_ , NormalCompletion(*true* )).
@@ -578,9 +568,8 @@ <h1>Iterator.prototype.every ( _predicate_ )</h1>
578
568
1. Let _iterated_ be ? GetIteratorDirect(_O_ ).
579
569
1. Let _counter_ be 0.
580
570
1. Repeat,
581
- 1. Let _next_ be ? IteratorStep(_iterated_ ).
582
- 1. If _next_ is *false* , return *true* .
583
- 1. Let _value_ be ? IteratorValue(_next_ ).
571
+ 1. Let _value_ be ? IteratorStepValue(_iterated_ ).
572
+ 1. If _value_ is ~done~ , return *true* .
584
573
1. Let _result_ be Completion(Call(_predicate_ , *undefined* , « _value_ , 𝔽(_counter_ ) »)).
585
574
1. IfAbruptCloseIterator(_result_ , _iterated_ ).
586
575
1. If ToBoolean(_result_ ) is *false* , return ? IteratorClose(_iterated_ , NormalCompletion(*false* )).
@@ -598,9 +587,8 @@ <h1>Iterator.prototype.find ( _predicate_ )</h1>
598
587
1. Let _iterated_ be ? GetIteratorDirect(_O_ ).
599
588
1. Let _counter_ be 0.
600
589
1. Repeat,
601
- 1. Let _next_ be ? IteratorStep(_iterated_ ).
602
- 1. If _next_ is *false* , return *undefined* .
603
- 1. Let _value_ be ? IteratorValue(_next_ ).
590
+ 1. Let _value_ be ? IteratorStepValue(_iterated_ ).
591
+ 1. If _value_ is ~done~ , return *undefined* .
604
592
1. Let _result_ be Completion(Call(_predicate_ , *undefined* , « _value_ , 𝔽(_counter_ ) »)).
605
593
1. IfAbruptCloseIterator(_result_ , _iterated_ ).
606
594
1. If ToBoolean(_result_ ) is *true* , return ? IteratorClose(_iterated_ , NormalCompletion(_value_ )).
0 commit comments