Skip to content

Commit

Permalink
Editorial: Specify Map/Set forEach more explicitly
Browse files Browse the repository at this point in the history
  • Loading branch information
bakkot committed May 3, 2022
1 parent fb5e39a commit e285fed
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions spec.html
Original file line number Diff line number Diff line change
Expand Up @@ -39885,9 +39885,15 @@ <h1>Map.prototype.forEach ( _callbackfn_ [ , _thisArg_ ] )</h1>
1. Perform ? RequireInternalSlot(_M_, [[MapData]]).
1. If IsCallable(_callbackfn_) is *false*, throw a *TypeError* exception.
1. Let _entries_ be the List that is _M_.[[MapData]].
1. For each Record { [[Key]], [[Value]] } _e_ of _entries_, do
1. Let _index_ be 0.
1. Let _numEntries_ be the number of elements of _entries_.
1. Repeat, while _index_ &lt; _numEntries_,
1. Let _e_ be the Record { [[Key]], [[Value]] } that is the value of _entries_[_index_].
1. Set _index_ to _index_ + 1.
1. If _e_.[[Key]] is not ~empty~, then
1. Perform ? Call(_callbackfn_, _thisArg_, &laquo; _e_.[[Value]], _e_.[[Key]], _M_ &raquo;).
1. NOTE: The number of elements in _entries_ may have increased during execution of _callbackfn_.
1. Set _numEntries_ to the number of elements of _entries_.
1. Return *undefined*.
</emu-alg>
<emu-note>
Expand Down Expand Up @@ -40022,7 +40028,7 @@ <h1>
1. Assert: _kind_ is ~key+value~.
1. Let _result_ be CreateArrayFromList(&laquo; _e_.[[Key]], _e_.[[Value]] &raquo;).
1. Perform ? GeneratorYield(CreateIterResultObject(_result_, *false*)).
1. NOTE: The number of elements in _entries_ may have changed while execution of this abstract operation was paused by Yield.
1. NOTE: The number of elements in _entries_ may have increased while execution of this abstract operation was paused by Yield.
1. Set _numEntries_ to the number of elements of _entries_.
1. Return *undefined*.
1. Return CreateIteratorFromClosure(_closure_, *"%MapIteratorPrototype%"*, %MapIteratorPrototype%).
Expand Down Expand Up @@ -40203,10 +40209,16 @@ <h1>Set.prototype.forEach ( _callbackfn_ [ , _thisArg_ ] )</h1>
1. Let _S_ be the *this* value.
1. Perform ? RequireInternalSlot(_S_, [[SetData]]).
1. If IsCallable(_callbackfn_) is *false*, throw a *TypeError* exception.
1. Let _entries_ be the List that is _S_.[[SetData]].
1. For each element _e_ of _entries_, do
1. Let _index_ be 0.
1. Let _entries_ be the List that is _set_.[[SetData]].
1. Let _numEntries_ be the number of elements of _entries_.
1. Repeat, while _index_ &lt; _numEntries_,
1. Let _e_ be _entries_[_index_].
1. Set _index_ to _index_ + 1.
1. If _e_ is not ~empty~, then
1. Perform ? Call(_callbackfn_, _thisArg_, &laquo; _e_, _e_, _S_ &raquo;).
1. NOTE: The number of elements in _entries_ may have increased during execution of _callbackfn_.
1. Set _numEntries_ to the number of elements of _entries_.
1. Return *undefined*.
</emu-alg>
<emu-note>
Expand Down Expand Up @@ -40311,7 +40323,7 @@ <h1>
1. Else,
1. Assert: _kind_ is ~value~.
1. Perform ? GeneratorYield(CreateIterResultObject(_e_, *false*)).
1. NOTE: The number of elements in _entries_ may have changed while execution of this abstract operation was paused by Yield.
1. NOTE: The number of elements in _entries_ may have increased while execution of this abstract operation was paused by Yield.
1. Set _numEntries_ to the number of elements of _entries_.
1. Return *undefined*.
1. Return CreateIteratorFromClosure(_closure_, *"%SetIteratorPrototype%"*, %SetIteratorPrototype%).
Expand Down

0 comments on commit e285fed

Please sign in to comment.