Skip to content
Permalink
Browse files

Editorial: Name internal slots of iterators consistently

  • Loading branch information
shvaikalesh authored and michaelficarra committed Jun 10, 2019
1 parent 17ff6d5 commit 96464b934c270aedd876eb644a15cb978a89b067
Showing with 31 additions and 31 deletions.
  1. +31 −31 spec.html
@@ -6046,9 +6046,9 @@ <h1>CreateIterResultObject ( _value_, _done_ )</h1>
<h1>CreateListIteratorRecord ( _list_ )</h1>
<p>The abstract operation CreateListIteratorRecord with argument _list_ creates an Iterator (<emu-xref href="#sec-iterator-interface"></emu-xref>) object record whose next method returns the successive elements of _list_. It performs the following steps:</p>
<emu-alg>
1. Let _iterator_ be ObjectCreate(%IteratorPrototype%, &laquo; [[IteratedList]], [[ListIteratorNextIndex]] &raquo;).
1. Let _iterator_ be ObjectCreate(%IteratorPrototype%, &laquo; [[IteratedList]], [[ListNextIndex]] &raquo;).
1. Set _iterator_.[[IteratedList]] to _list_.
1. Set _iterator_.[[ListIteratorNextIndex]] to 0.
1. Set _iterator_.[[ListNextIndex]] to 0.
1. Let _steps_ be the algorithm steps defined in <emu-xref href="#sec-listiteratornext-functions" title></emu-xref>.
1. Let _next_ be ! CreateBuiltinFunction(_steps_, &laquo; &raquo;).
1. Return Record { [[Iterator]]: _iterator_, [[NextMethod]]: _next_, [[Done]]: *false* }.
@@ -6065,11 +6065,11 @@ <h1>ListIteratorNext Functions</h1>
1. Assert: Type(_O_) is Object.
1. Assert: _O_ has an [[IteratedList]] internal slot.
1. Let _list_ be _O_.[[IteratedList]].
1. Let _index_ be _O_.[[ListIteratorNextIndex]].
1. Let _index_ be _O_.[[ListNextIndex]].
1. Let _len_ be the number of elements of _list_.
1. If _index_ &ge; _len_, then
1. Return CreateIterResultObject(*undefined*, *true*).
1. Set _O_.[[ListIteratorNextIndex]] to _index_ + 1.
1. Set _O_.[[ListNextIndex]] to _index_ + 1.
1. Return CreateIterResultObject(_list_[_index_], *false*).
</emu-alg>
<p>The *"length"* property of a ListIteratorNext function is 0.</p>
<p>Several methods of String objects return Iterator objects. The abstract operation CreateStringIterator with argument _string_ is used to create such iterator objects. It performs the following steps:</p>
<emu-alg>
1. Assert: Type(_string_) is String.
1. Let _iterator_ be ObjectCreate(%StringIteratorPrototype%, &laquo; [[IteratedString]], [[StringIteratorNextIndex]] &raquo;).
1. Let _iterator_ be ObjectCreate(%StringIteratorPrototype%, &laquo; [[IteratedString]], [[StringNextIndex]] &raquo;).
1. Set _iterator_.[[IteratedString]] to _string_.
1. Set _iterator_.[[StringIteratorNextIndex]] to 0.
1. Set _iterator_.[[StringNextIndex]] to 0.
1. Return _iterator_.
</emu-alg>
</emu-clause>
1. If _O_ does not have all of the internal slots of a String Iterator Instance (<emu-xref href="#sec-properties-of-string-iterator-instances"></emu-xref>), throw a *TypeError* exception.
1. Let _s_ be _O_.[[IteratedString]].
1. If _s_ is *undefined*, return CreateIterResultObject(*undefined*, *true*).
1. Let _position_ be _O_.[[StringIteratorNextIndex]].
1. Let _position_ be _O_.[[StringNextIndex]].
1. Let _len_ be the length of _s_.
1. If _position_ &ge; _len_, then
1. Set _O_.[[IteratedString]] to *undefined*.
1. Return CreateIterResultObject(*undefined*, *true*).
1. Let _cp_ be ! CodePointAt(_s_, _position_).
1. Let _resultString_ be the String value containing _cp_.[[CodeUnitCount]] consecutive code units from _s_ beginning with the code unit at index _position_.
1. Set _O_.[[StringIteratorNextIndex]] to _position_ + _cp_.[[CodeUnitCount]].
1. Set _O_.[[StringNextIndex]] to _position_ + _cp_.[[CodeUnitCount]].
1. Return CreateIterResultObject(_resultString_, *false*).
</emu-alg>
</emu-clause>
</tr>
<tr>
<td>
[[StringIteratorNextIndex]]
[[StringNextIndex]]
</td>
<td>
The integer index of the next string index to be examined by this iteration.
The integer index of the next code unit to be examined by this iterator.
</td>
</tr>
</tbody>
<p>Several methods of Array objects return Iterator objects. The abstract operation CreateArrayIterator with arguments _array_ and _kind_ is used to create such iterator objects. It performs the following steps:</p>
<emu-alg>
1. Assert: Type(_array_) is Object.
1. Let _iterator_ be ObjectCreate(%ArrayIteratorPrototype%, &laquo; [[IteratedObject]], [[ArrayIteratorNextIndex]], [[ArrayIterationKind]] &raquo;).
1. Set _iterator_.[[IteratedObject]] to _array_.
1. Set _iterator_.[[ArrayIteratorNextIndex]] to 0.
1. Set _iterator_.[[ArrayIterationKind]] to _kind_.
1. Let _iterator_ be ObjectCreate(%ArrayIteratorPrototype%, &laquo; [[IteratedArrayLike]], [[ArrayLikeNextIndex]], [[ArrayLikeIterationKind]] &raquo;).
1. Set _iterator_.[[IteratedArrayLike]] to _array_.
1. Set _iterator_.[[ArrayLikeNextIndex]] to 0.
1. Set _iterator_.[[ArrayLikeIterationKind]] to _kind_.
1. Return _iterator_.
</emu-alg>
</emu-clause>
1. Let _O_ be the *this* value.
1. If Type(_O_) is not Object, throw a *TypeError* exception.
1. If _O_ does not have all of the internal slots of an Array Iterator Instance (<emu-xref href="#sec-properties-of-array-iterator-instances"></emu-xref>), throw a *TypeError* exception.
1. Let _a_ be _O_.[[IteratedObject]].
1. Let _a_ be _O_.[[IteratedArrayLike]].
1. If _a_ is *undefined*, return CreateIterResultObject(*undefined*, *true*).
1. Let _index_ be _O_.[[ArrayIteratorNextIndex]].
1. Let _itemKind_ be _O_.[[ArrayIterationKind]].
1. Let _index_ be _O_.[[ArrayLikeNextIndex]].
1. Let _itemKind_ be _O_.[[ArrayLikeIterationKind]].
1. If _a_ has a [[TypedArrayName]] internal slot, then
1. If IsDetachedBuffer(_a_.[[ViewedArrayBuffer]]) is *true*, throw a *TypeError* exception.
1. Let _len_ be _a_.[[ArrayLength]].
1. Else,
1. Let _len_ be ? LengthOfArrayLike(_a_).
1. If _index_ &ge; _len_, then
1. Set _O_.[[IteratedObject]] to *undefined*.
1. Set _O_.[[IteratedArrayLike]] to *undefined*.
1. Return CreateIterResultObject(*undefined*, *true*).
1. Set _O_.[[ArrayIteratorNextIndex]] to _index_ + 1.
1. Set _O_.[[ArrayLikeNextIndex]] to _index_ + 1.
1. If _itemKind_ is ~key~, return CreateIterResultObject(_index_, *false*).
1. Let _elementKey_ be ! ToString(_index_).
1. Let _elementValue_ be ? Get(_a_, _elementKey_).
</tr>
<tr>
<td>
[[IteratedObject]]
[[IteratedArrayLike]]
</td>
<td>
The object whose array elements are being iterated.
The array-like object that is being iterated.
</td>
</tr>
<tr>
<td>
[[ArrayIteratorNextIndex]]
[[ArrayLikeNextIndex]]
</td>
<td>
The integer index of the next integer index to be examined by this iteration.
The integer index of the next element to be examined by this iterator.
</td>
</tr>
<tr>
<td>
[[ArrayIterationKind]]
[[ArrayLikeIterationKind]]
</td>
<td>
A String value that identifies what is returned for each element of the iteration. The possible values are: ~key~, ~value~, ~key+value~.
<p>Several methods of Map objects return Iterator objects. The abstract operation CreateMapIterator with arguments _map_ and _kind_ is used to create such iterator objects. It performs the following steps:</p>
<emu-alg>
1. Perform ? RequireInternalSlot(_map_, [[MapData]]).
1. Let _iterator_ be ObjectCreate(%MapIteratorPrototype%, &laquo; [[Map]], [[MapNextIndex]], [[MapIterationKind]] &raquo;).
1. Set _iterator_.[[Map]] to _map_.
1. Let _iterator_ be ObjectCreate(%MapIteratorPrototype%, &laquo; [[IteratedMap]], [[MapNextIndex]], [[MapIterationKind]] &raquo;).
1. Set _iterator_.[[IteratedMap]] to _map_.
1. Set _iterator_.[[MapNextIndex]] to 0.
1. Set _iterator_.[[MapIterationKind]] to _kind_.
1. Return _iterator_.
1. Let _O_ be the *this* value.
1. If Type(_O_) is not Object, throw a *TypeError* exception.
1. If _O_ does not have all of the internal slots of a Map Iterator Instance (<emu-xref href="#sec-properties-of-map-iterator-instances"></emu-xref>), throw a *TypeError* exception.
1. Let _m_ be _O_.[[Map]].
1. Let _m_ be _O_.[[IteratedMap]].
1. Let _index_ be _O_.[[MapNextIndex]].
1. Let _itemKind_ be _O_.[[MapIterationKind]].
1. If _m_ is *undefined*, return CreateIterResultObject(*undefined*, *true*).
1. Assert: _itemKind_ is ~key+value~.
1. Let _result_ be ! CreateArrayFromList(&laquo; _e_.[[Key]], _e_.[[Value]] &raquo;).
1. Return CreateIterResultObject(_result_, *false*).
1. Set _O_.[[Map]] to *undefined*.
1. Set _O_.[[IteratedMap]] to *undefined*.
1. Return CreateIterResultObject(*undefined*, *true*).
</emu-alg>
</emu-clause>
</tr>
<tr>
<td>
[[Map]]
[[IteratedMap]]
</td>
<td>
The Map object that is being iterated.
[[MapNextIndex]]
</td>
<td>
The integer index of the next Map data element to be examined by this iterator.
The integer index of the next [[MapData]] element to be examined by this iterator.
</td>
</tr>
<tr>
[[SetNextIndex]]
</td>
<td>
The integer index of the next Set data element to be examined by this iterator
The integer index of the next [[SetData]] element to be examined by this iterator.
</td>
</tr>
<tr>

0 comments on commit 96464b9

Please sign in to comment.
You can’t perform that action at this time.