From e285fede94def1242a2b4089341d1c0e514abba9 Mon Sep 17 00:00:00 2001 From: Kevin Gibbons Date: Tue, 3 May 2022 09:39:31 -0700 Subject: [PATCH] Editorial: Specify Map/Set forEach more explicitly --- spec.html | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/spec.html b/spec.html index 4e6586488c..e6fcac14e0 100644 --- a/spec.html +++ b/spec.html @@ -39885,9 +39885,15 @@

Map.prototype.forEach ( _callbackfn_ [ , _thisArg_ ] )

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_ < _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_, « _e_.[[Value]], _e_.[[Key]], _M_ »). + 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*. @@ -40022,7 +40028,7 @@

1. Assert: _kind_ is ~key+value~. 1. Let _result_ be CreateArrayFromList(« _e_.[[Key]], _e_.[[Value]] »). 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%). @@ -40203,10 +40209,16 @@

Set.prototype.forEach ( _callbackfn_ [ , _thisArg_ ] )

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_ < _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_, « _e_, _e_, _S_ »). + 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*. @@ -40311,7 +40323,7 @@

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%).