- Toggle shortcuts help
?
- Toggle "can call user code" annotations
u
- Jump to search box
/
- Toggle pinning of the current clause
p
- Jump to nth pin
1-9
Stage 2.7 Draft / October 10, 2024
Iterator Sequencing
1 Iterator.concat ( ...items )
- Let iterables be a new empty List.
- For each element item of items, do
- If item is not an Object, throw a TypeError exception.
- Let method be ? GetMethod(item, %Symbol.iterator%).
- If method is undefined, throw a TypeError exception.
- Append the Record { [[OpenMethod]]: method, [[Iterable]]: item } to iterables.
- Let closure be a new Abstract Closure with no parameters that captures iterables and performs the following steps when called:
- For each Record iterable of iterables, do
- Let iter be ? Call(iterable.[[OpenMethod]], iterable.[[Iterable]]).
- If iter is not an Object, throw a TypeError exception.
- Let iteratorRecord be ? GetIteratorDirect(iter).
- Let innerAlive be true.
- Repeat, while innerAlive is true,
- Let innerValue be ? IteratorStepValue(iteratorRecord).
- If innerValue is done, then
- Set innerAlive to false.
- Else,
- Let completion be Completion(Yield(innerValue)).
- If completion is an abrupt completion, then
- Return ? IteratorClose(iteratorRecord, completion).
- Return ReturnCompletion(undefined).
- Let gen be CreateIteratorFromClosure(closure, "Iterator Helper", %IteratorHelperPrototype%, « [[UnderlyingIterators]] »).
- Set gen.[[UnderlyingIterators]] to a new empty List.
- Return gen.