This repository was archived by the owner on Jan 26, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 37
/
Copy pathiterator-operations.html
45 lines (43 loc) · 2.35 KB
/
iterator-operations.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<emu-clause id="sec-getasynciterator" aoid="GetAsyncIterator">
<h1>GetAsyncIterator ( _obj_ )</h1>
<p>The abstract operation GetAsyncIterator with argument _obj_ performs the following steps:</p>
<emu-alg>
1. Let _method_ be ? GetMethod(_obj_, @@asyncIterator).
1. If _method_ is *undefined*, let *method* be ? GetMethod(_obj_, @@iterator).
1. Let _iterator_ be ? Call(_method_, _obj_).
1. If Type(_iterator_) is not Object, throw a *TypeError* exception.
1. Return _iterator_.
</emu-alg>
</emu-clause>
<emu-clause id="sec-iteratorclose" aoid="IteratorClose">
<h1>IteratorClose( _iterator_, _completion_, _iteratorKind_ )</h1>
<p>The abstract operation IteratorClose with arguments _iterator_ and _completion_ and optional argument _iteratorKind_ is used to notify an iterator that it should perform any actions it would normally perform when it has reached its completed state. The value of _iteratorKind_ is either ~normal~ or ~async~.</p>
<emu-alg>
1. Assert: Type(_iterator_) is Object.
1. Assert: _completion_ is a Completion Record.
1. If _iteratorKind_ was not passed, let _iteratorKind_ be ~normal~.
1. Let _return_ be ? GetMethod(_iterator_, `"return"`).
1. If _return_ is *undefined*, then
1. Return Completion(_completion_).
1. Let _innerResult_ be Call(_return_, _iterator_, « »).
1. If _innerResult_ is not an abrupt completion and _iteratorKind_ is ~async~, then
1. Let _innerResult_ be AwaitIterResultObject(_innerResult_).
1. If _completion_.[[type]] is ~throw~, return Completion(_completion_).
1. If _innerResult_.[[type]] is ~throw~, return Completion(_innerResult_).
1. If Type(_innerResult_.[[value]]) is not Object, throw a *TypeError* exception.
1. Return Completion(_completion_).
</emu-alg>
</emu-clause>
<emu-clause id="sec-awaititerresultobject" aoid="AwaitIterResultObject">
<h1>AwaitIterResultObject ( _asyncResult_ )</h1>
<emu-alg>
1. Let _result_ be ? AsyncFunctionAwait(_asyncResult_).
1. Let _value_ be ? IteratorValue(_result_).
1. If Type(_value_) is Object, then
1. If ? IsCallable(? Get(_value_, `"then"`)) is *true*, then
1. Let _done_ be ? IteratorComplete(_result_).
1. Let _value_ be ? AsyncFunctionAwait(_value_).
1. Let _result_ be CreateIterResultObject(_value_, _done_).
1. Return _result_.
</emu-alg>
</emu-clause>