Skip to content

Commit e7b8ed8

Browse files
Normative: add Iterator.concat
1 parent ceb5a30 commit e7b8ed8

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

spec.html

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48086,6 +48086,36 @@ <h1>Properties of the Iterator Constructor</h1>
4808648086
<li>has the following properties:</li>
4808748087
</ul>
4808848088

48089+
<emu-clause id="sec-iterator.concat">
48090+
<h1>Iterator.concat ( ..._items_ )</h1>
48091+
<emu-alg>
48092+
1. Let _iterables_ be a new empty List.
48093+
1. For each element _item_ of _items_, do
48094+
1. If _item_ is not an Object, throw a *TypeError* exception.
48095+
1. Let _method_ be ? GetMethod(_item_, %Symbol.iterator%).
48096+
1. If _method_ is *undefined*, throw a *TypeError* exception.
48097+
1. Append the Record { [[OpenMethod]]: _method_, [[Iterable]]: _item_ } to _iterables_.
48098+
1. Let _closure_ be a new Abstract Closure with no parameters that captures _iterables_ and performs the following steps when called:
48099+
1. For each Record _iterable_ of _iterables_, do
48100+
1. Let _iter_ be ? Call(_iterable_.[[OpenMethod]], _iterable_.[[Iterable]]).
48101+
1. If _iter_ is not an Object, throw a *TypeError* exception.
48102+
1. Let _iteratorRecord_ be ? GetIteratorDirect(_iter_).
48103+
1. Let _innerAlive_ be *true*.
48104+
1. Repeat, while _innerAlive_ is *true*,
48105+
1. Let _innerValue_ be ? IteratorStepValue(_iteratorRecord_).
48106+
1. If _innerValue_ is ~done~, then
48107+
1. Set _innerAlive_ to *false*.
48108+
1. Else,
48109+
1. Let _completion_ be Completion(Yield(_innerValue_)).
48110+
1. If _completion_ is an abrupt completion, then
48111+
1. Return ? IteratorClose(_iteratorRecord_, _completion_).
48112+
1. Return ReturnCompletion(*undefined*).
48113+
1. Let _gen_ be CreateIteratorFromClosure(_closure_, *"Iterator Helper"*, %IteratorHelperPrototype%, « [[UnderlyingIterators]] »).
48114+
1. Set _gen_.[[UnderlyingIterators]] to a new empty List.
48115+
1. Return _gen_.
48116+
</emu-alg>
48117+
</emu-clause>
48118+
4808948119
<emu-clause id="sec-iterator.from">
4809048120
<h1>Iterator.from ( _O_ )</h1>
4809148121
<emu-alg>

0 commit comments

Comments
 (0)