Skip to content
This repository was archived by the owner on Oct 8, 2024. It is now read-only.

Commit b4ccc31

Browse files
authored
Editorial: use new IteratorStepValue AO (#292)
1 parent f1427ec commit b4ccc31

File tree

3 files changed

+38
-50
lines changed

3 files changed

+38
-50
lines changed

package-lock.json

Lines changed: 8 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"check-format": "emu-format --check spec.html"
88
},
99
"devDependencies": {
10-
"@tc39/ecma262-biblio": "2.1.2407",
10+
"@tc39/ecma262-biblio": "2.1.2678",
1111
"ecmarkup": "^15.0.0"
1212
}
1313
}

spec.html

Lines changed: 29 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -350,9 +350,8 @@ <h1>Iterator.prototype.map ( _mapper_ )</h1>
350350
1. Let _closure_ be a new Abstract Closure with no parameters that captures _iterated_ and _mapper_ and performs the following steps when called:
351351
1. Let _counter_ be 0.
352352
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*.
356355
1. Let _mapped_ be Completion(Call(_mapper_, *undefined*, « _value_, 𝔽(_counter_) »)).
357356
1. IfAbruptCloseIterator(_mapped_, _iterated_).
358357
1. Let _completion_ be Completion(Yield(_mapped_)).
@@ -375,9 +374,8 @@ <h1>Iterator.prototype.filter ( _predicate_ )</h1>
375374
1. Let _closure_ be a new Abstract Closure with no parameters that captures _iterated_ and _predicate_ and performs the following steps when called:
376375
1. Let _counter_ be 0.
377376
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*.
381379
1. Let _selected_ be Completion(Call(_predicate_, *undefined*, « _value_, 𝔽(_counter_) »)).
382380
1. IfAbruptCloseIterator(_selected_, _iterated_).
383381
1. If ToBoolean(_selected_) is *true*, then
@@ -408,9 +406,9 @@ <h1>Iterator.prototype.take ( _limit_ )</h1>
408406
1. Return ? IteratorClose(_iterated_, NormalCompletion(*undefined*)).
409407
1. If _remaining_ is not +∞, then
410408
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_)).
414412
1. IfAbruptCloseIterator(_completion_, _iterated_).
415413
1. Let _result_ be CreateIteratorFromClosure(_closure_, *"Iterator Helper"*, %IteratorHelperPrototype%, « [[UnderlyingIterator]] »).
416414
1. Set _result_.[[UnderlyingIterator]] to _iterated_.
@@ -437,9 +435,9 @@ <h1>Iterator.prototype.drop ( _limit_ )</h1>
437435
1. Let _next_ be ? IteratorStep(_iterated_).
438436
1. If _next_ is *false*, return *undefined*.
439437
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_)).
443441
1. IfAbruptCloseIterator(_completion_, _iterated_).
444442
1. Let _result_ be CreateIteratorFromClosure(_closure_, *"Iterator Helper"*, %IteratorHelperPrototype%, « [[UnderlyingIterator]] »).
445443
1. Set _result_.[[UnderlyingIterator]] to _iterated_.
@@ -458,22 +456,19 @@ <h1>Iterator.prototype.flatMap ( _mapper_ )</h1>
458456
1. Let _closure_ be a new Abstract Closure with no parameters that captures _iterated_ and _mapper_ and performs the following steps when called:
459457
1. Let _counter_ be 0.
460458
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*.
464461
1. Let _mapped_ be Completion(Call(_mapper_, *undefined*, « _value_, 𝔽(_counter_) »)).
465462
1. IfAbruptCloseIterator(_mapped_, _iterated_).
466463
1. Let _innerIterator_ be Completion(GetIteratorFlattenable(_mapped_, ~reject-strings~)).
467464
1. IfAbruptCloseIterator(_innerIterator_, _iterated_).
468465
1. Let _innerAlive_ be *true*.
469466
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
473470
1. Set _innerAlive_ to *false*.
474471
1. Else,
475-
1. Let _innerValue_ be Completion(IteratorValue(_innerNext_)).
476-
1. IfAbruptCloseIterator(_innerValue_, _iterated_).
477472
1. Let _completion_ be Completion(Yield(_innerValue_)).
478473
1. If _completion_ is an abrupt completion, then
479474
1. Let _backupCompletion_ be Completion(IteratorClose(_innerIterator_, _completion_)).
@@ -495,17 +490,15 @@ <h1>Iterator.prototype.reduce ( _reducer_ [ , _initialValue_ ] )</h1>
495490
1. If IsCallable(_reducer_) is *false*, throw a *TypeError* exception.
496491
1. Let _iterated_ be ? GetIteratorDirect(_O_).
497492
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.
501495
1. Let _counter_ be 1.
502496
1. Else,
503497
1. Let _accumulator_ be _initialValue_.
504498
1. Let _counter_ be 0.
505499
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_.
509502
1. Let _result_ be Completion(Call(_reducer_, *undefined*, « _accumulator_, _value_, 𝔽(_counter_) »)).
510503
1. IfAbruptCloseIterator(_result_, _iterated_).
511504
1. Set _accumulator_ to _result_.[[Value]].
@@ -522,9 +515,8 @@ <h1>Iterator.prototype.toArray ( )</h1>
522515
1. Let _iterated_ be ? GetIteratorDirect(_O_).
523516
1. Let _items_ be a new empty List.
524517
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_).
528520
1. Append _value_ to _items_.
529521
</emu-alg>
530522
</emu-clause>
@@ -539,9 +531,8 @@ <h1>Iterator.prototype.forEach ( _fn_ )</h1>
539531
1. Let _iterated_ be ? GetIteratorDirect(_O_).
540532
1. Let _counter_ be 0.
541533
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*.
545536
1. Let _result_ be Completion(Call(_fn_, *undefined*, « _value_, 𝔽(_counter_) »)).
546537
1. IfAbruptCloseIterator(_result_, _iterated_).
547538
1. Set _counter_ to _counter_ + 1.
@@ -558,9 +549,8 @@ <h1>Iterator.prototype.some ( _predicate_ )</h1>
558549
1. Let _iterated_ be ? GetIteratorDirect(_O_).
559550
1. Let _counter_ be 0.
560551
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*.
564554
1. Let _result_ be Completion(Call(_predicate_, *undefined*, « _value_, 𝔽(_counter_) »)).
565555
1. IfAbruptCloseIterator(_result_, _iterated_).
566556
1. If ToBoolean(_result_) is *true*, return ? IteratorClose(_iterated_, NormalCompletion(*true*)).
@@ -578,9 +568,8 @@ <h1>Iterator.prototype.every ( _predicate_ )</h1>
578568
1. Let _iterated_ be ? GetIteratorDirect(_O_).
579569
1. Let _counter_ be 0.
580570
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*.
584573
1. Let _result_ be Completion(Call(_predicate_, *undefined*, « _value_, 𝔽(_counter_) »)).
585574
1. IfAbruptCloseIterator(_result_, _iterated_).
586575
1. If ToBoolean(_result_) is *false*, return ? IteratorClose(_iterated_, NormalCompletion(*false*)).
@@ -598,9 +587,8 @@ <h1>Iterator.prototype.find ( _predicate_ )</h1>
598587
1. Let _iterated_ be ? GetIteratorDirect(_O_).
599588
1. Let _counter_ be 0.
600589
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*.
604592
1. Let _result_ be Completion(Call(_predicate_, *undefined*, « _value_, 𝔽(_counter_) »)).
605593
1. IfAbruptCloseIterator(_result_, _iterated_).
606594
1. If ToBoolean(_result_) is *true*, return ? IteratorClose(_iterated_, NormalCompletion(_value_)).

0 commit comments

Comments
 (0)