Skip to content

Commit

Permalink
Editorial: Add Iterator Record type
Browse files Browse the repository at this point in the history
  • Loading branch information
ExE-Boss committed Nov 28, 2021
1 parent c5f683e commit e1987d5
Showing 1 changed file with 63 additions and 9 deletions.
72 changes: 63 additions & 9 deletions spec.html
Original file line number Diff line number Diff line change
Expand Up @@ -6978,6 +6978,60 @@ <h1>
<h1>Operations on Iterator Objects</h1>
<p>See Common Iteration Interfaces (<emu-xref href="#sec-iteration"></emu-xref>).</p>

<emu-clause id="sec-iterator-records">
<h1>Iterator Records</h1>
<p>A <dfn variants="Iterator Records">Iterator Record</dfn> is a Record value used to encapsulate an Iterator or AsyncIterator along with the `next` method.</p>
<p>Iterator Records have the fields listed in <emu-xref href="#table-iterator-record-fields"></emu-xref>.</p>
<emu-table id="table-iterator-record-fields" caption="Iterator Record Fields">
<table>
<tr>
<th>
Field Name
</th>
<th>
Value
</th>
<th>
Meaning
</th>
</tr>
<tr>
<td>
[[Iterator]]
</td>
<td>
An object
</td>
<td>
An object that conforms to the <emu-xref href="#sec-iterator-interface">Iterator</emu-xref> or <emu-xref href="#sec-asynciterator-interface">AsyncIterator</emu-xref> interface.
</td>
</tr>
<tr>
<td>
[[NextMethod]]
</td>
<td>
A function object
</td>
<td>
The `next` method of the [[Iterator]] object.
</td>
</tr>
<tr>
<td>
[[Done]]
</td>
<td>
Boolean
</td>
<td>
Whether the iterator has been closed.
</td>
</tr>
</table>
</emu-table>
</emu-clause>

<emu-clause id="sec-getiterator" type="abstract operation">
<h1>
GetIterator (
Expand All @@ -7001,15 +7055,15 @@ <h1>
1. Let _iterator_ be ? Call(_method_, _obj_).
1. If Type(_iterator_) is not Object, throw a *TypeError* exception.
1. Let _nextMethod_ be ? GetV(_iterator_, *"next"*).
1. Let _iteratorRecord_ be the Record { [[Iterator]]: _iterator_, [[NextMethod]]: _nextMethod_, [[Done]]: *false* }.
1. Let _iteratorRecord_ be the Iterator Record { [[Iterator]]: _iterator_, [[NextMethod]]: _nextMethod_, [[Done]]: *false* }.
1. Return _iteratorRecord_.
</emu-alg>
</emu-clause>

<emu-clause id="sec-iteratornext" type="abstract operation">
<h1>
IteratorNext (
_iteratorRecord_: unknown,
_iteratorRecord_: an Iterator Record,
optional _value_: unknown,
)
</h1>
Expand Down Expand Up @@ -7054,7 +7108,7 @@ <h1>
<emu-clause id="sec-iteratorstep" type="abstract operation">
<h1>
IteratorStep (
_iteratorRecord_: unknown,
_iteratorRecord_: an Iterator Record,
)
</h1>
<dl class="header">
Expand All @@ -7072,7 +7126,7 @@ <h1>
<emu-clause id="sec-iteratorclose" type="abstract operation">
<h1>
IteratorClose (
_iteratorRecord_: unknown,
_iteratorRecord_: an Iterator Record,
_completion_: a Completion Record,
)
</h1>
Expand Down Expand Up @@ -7111,7 +7165,7 @@ <h1>IfAbruptCloseIterator ( _value_, _iteratorRecord_ )</h1>
<emu-clause id="sec-asynciteratorclose" type="abstract operation">
<h1>
AsyncIteratorClose (
_iteratorRecord_: unknown,
_iteratorRecord_: an Iterator Record,
_completion_: a Completion Record,
)
</h1>
Expand Down Expand Up @@ -7170,7 +7224,7 @@ <h1>
1. Perform ? Yield(_E_).
1. Return *undefined*.
1. Let _iterator_ be ! CreateIteratorFromClosure(_closure_, ~empty~, %IteratorPrototype%).
1. Return Record { [[Iterator]]: _iterator_, [[NextMethod]]: %GeneratorFunction.prototype.prototype.next%, [[Done]]: *false* }.
1. Return the Iterator Record { [[Iterator]]: _iterator_, [[NextMethod]]: %GeneratorFunction.prototype.prototype.next%, [[Done]]: *false* }.
</emu-alg>
<emu-note>
<p>The list iterator object is never directly accessible to ECMAScript code.</p>
Expand Down Expand Up @@ -22043,7 +22097,7 @@ <h1>
1. Let _obj_ be ! ToObject(_exprValue_).
1. Let _iterator_ be ? EnumerateObjectProperties(_obj_).
1. Let _nextMethod_ be ! GetV(_iterator_, *"next"*).
1. Return the Record { [[Iterator]]: _iterator_, [[NextMethod]]: _nextMethod_, [[Done]]: *false* }.
1. Return the Iterator Record { [[Iterator]]: _iterator_, [[NextMethod]]: _nextMethod_, [[Done]]: *false* }.
1. Else,
1. Assert: _iterationKind_ is ~iterate~ or ~async-iterate~.
1. If _iterationKind_ is ~async-iterate~, let _iteratorHint_ be ~async~.
Expand Down Expand Up @@ -42994,13 +43048,13 @@ <h1>
</h1>
<dl class="header">
<dt>description</dt>
<dd>It is used to create an async iterator Record from a synchronous iterator Record.</dd>
<dd>It is used to create an async Iterator Record from a synchronous Iterator Record.</dd>
</dl>
<emu-alg>
1. Let _asyncIterator_ be ! OrdinaryObjectCreate(%AsyncFromSyncIteratorPrototype%, &laquo; [[SyncIteratorRecord]] &raquo;).
1. Set _asyncIterator_.[[SyncIteratorRecord]] to _syncIteratorRecord_.
1. Let _nextMethod_ be ! Get(_asyncIterator_, *"next"*).
1. Let _iteratorRecord_ be the Record { [[Iterator]]: _asyncIterator_, [[NextMethod]]: _nextMethod_, [[Done]]: *false* }.
1. Let _iteratorRecord_ be the Iterator Record { [[Iterator]]: _asyncIterator_, [[NextMethod]]: _nextMethod_, [[Done]]: *false* }.
1. Return _iteratorRecord_.
</emu-alg>
</emu-clause>
Expand Down

0 comments on commit e1987d5

Please sign in to comment.