Skip to content

Commit 42a9557

Browse files
Normative: add Iterator.concat
1 parent 1d2f604 commit 42a9557

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
@@ -48055,6 +48055,36 @@ <h1>Properties of the Iterator Constructor</h1>
4805548055
<li>has the following properties:</li>
4805648056
</ul>
4805748057

48058+
<emu-clause id="sec-iterator.concat">
48059+
<h1>Iterator.concat ( ..._items_ )</h1>
48060+
<emu-alg>
48061+
1. Let _iterables_ be a new empty List.
48062+
1. For each element _item_ of _items_, do
48063+
1. If _item_ is not an Object, throw a *TypeError* exception.
48064+
1. Let _method_ be ? GetMethod(_item_, %Symbol.iterator%).
48065+
1. If _method_ is *undefined*, throw a *TypeError* exception.
48066+
1. Append the Record { [[OpenMethod]]: _method_, [[Iterable]]: _item_ } to _iterables_.
48067+
1. Let _closure_ be a new Abstract Closure with no parameters that captures _iterables_ and performs the following steps when called:
48068+
1. For each Record _iterable_ of _iterables_, do
48069+
1. Let _iter_ be ? Call(_iterable_.[[OpenMethod]], _iterable_.[[Iterable]]).
48070+
1. If _iter_ is not an Object, throw a *TypeError* exception.
48071+
1. Let _iteratorRecord_ be ? GetIteratorDirect(_iter_).
48072+
1. Let _innerAlive_ be *true*.
48073+
1. Repeat, while _innerAlive_ is *true*,
48074+
1. Let _innerValue_ be ? IteratorStepValue(_iteratorRecord_).
48075+
1. If _innerValue_ is ~done~, then
48076+
1. Set _innerAlive_ to *false*.
48077+
1. Else,
48078+
1. Let _completion_ be Completion(Yield(_innerValue_)).
48079+
1. If _completion_ is an abrupt completion, then
48080+
1. Return ? IteratorClose(_iteratorRecord_, _completion_).
48081+
1. Return ReturnCompletion(*undefined*).
48082+
1. Let _gen_ be CreateIteratorFromClosure(_closure_, *"Iterator Helper"*, %IteratorHelperPrototype%, « [[UnderlyingIterators]] »).
48083+
1. Set _gen_.[[UnderlyingIterators]] to a new empty List.
48084+
1. Return _gen_.
48085+
</emu-alg>
48086+
</emu-clause>
48087+
4805848088
<emu-clause id="sec-iterator.from">
4805948089
<h1>Iterator.from ( _O_ )</h1>
4806048090
<emu-alg>

0 commit comments

Comments
 (0)