You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
): either a normal completion containing a List of Records with fields [[Key]] (an ECMAScript language value) and [[Elements]] (a List of ECMAScript language values), or a throw completion
6802
+
</h1>
6803
+
<dl class="header">
6804
+
</dl>
6805
+
<emu-alg>
6806
+
1. Perform ? RequireObjectCoercible(_items_).
6807
+
1. If IsCallable(_callbackfn_) is *false*, throw a *TypeError* exception.
6808
+
1. Let _groups_ be a new empty List.
6809
+
1. Let _iteratorRecord_ be ? GetIterator(_items_, ~sync~).
6810
+
1. Let _k_ be 0.
6811
+
1. Repeat,
6812
+
1. If _k_ ≥ 2<sup>53</sup> - 1, then
6813
+
1. Let _error_ be ThrowCompletion(a newly created *TypeError* object).
<p>_callbackfn_ should be a function that accepts two arguments. `groupBy` calls _callbackfn_ once for each element in _items_, in ascending order, and constructs a new object. Each value returned by _callbackfn_ is coerced to a property key. For each such property key, the result object has a property whose key is that property key and whose value is an array containing all the elements for which the _callbackfn_ return value coerced to that key.</p>
29861
+
<p>_callbackfn_ is called with two arguments: the value of the element and the index of the element.</p>
29862
+
<p>The return value of `groupBy` is an object that does not inherit from %Object.prototype%.</p>
29863
+
</emu-note>
29864
+
<p>This function performs the following steps when called:</p>
29865
+
<emu-alg>
29866
+
1. Let _groups_ be ? GroupBy(_items_, _callbackfn_, ~property~).
29867
+
1. Let _obj_ be OrdinaryObjectCreate(*null*).
29868
+
1. For each Record { [[Key]], [[Elements]] } _g_ of _groups_, do
29869
+
1. Let _elements_ be CreateArrayFromList(_g_.[[Elements]]).
<p>This function performs the following steps when called:</p>
@@ -41755,6 +41832,25 @@ <h1>Properties of the Map Constructor</h1>
41755
41832
<li>has the following properties:</li>
41756
41833
</ul>
41757
41834
41835
+
<emu-clause id="sec-map.groupby">
41836
+
<h1>Map.groupBy ( _items_, _callbackfn_ )</h1>
41837
+
<emu-note>
41838
+
<p>_callbackfn_ should be a function that accepts two arguments. `groupBy` calls _callbackfn_ once for each element in _items_, in ascending order, and constructs a new Map of arrays. Each value returned by _callbackfn_ is used as a key in the Map. For each such key, the result Map has an entry whose key is that key and whose value is an array containing all the elements for which _callbackfn_ returned that key.</p>
41839
+
<p>_callbackfn_ is called with two arguments: the value of the element and the index of the element.</p>
41840
+
<p>The return value of `groupBy` is a Map.</p>
41841
+
</emu-note>
41842
+
<p>This function performs the following steps when called:</p>
41843
+
<emu-alg>
41844
+
1. Let _groups_ be ? GroupBy(_items_, _callbackfn_, ~zero~).
41845
+
1. Let _map_ be ! Construct(%Map%).
41846
+
1. For each Record { [[Key]], [[Elements]] } _g_ of _groups_, do
41847
+
1. Let _elements_ be CreateArrayFromList(_g_.[[Elements]]).
41848
+
1. Let _entry_ be the Record { [[Key]]: _g_.[[Key]], [[Value]]: _elements_ }.
41849
+
1. Append _entry_ to _map_.[[MapData]].
41850
+
1. Return _map_.
41851
+
</emu-alg>
41852
+
</emu-clause>
41853
+
41758
41854
<emu-clause id="sec-map.prototype">
41759
41855
<h1>Map.prototype</h1>
41760
41856
<p>The initial value of `Map.prototype` is the Map prototype object.</p>
0 commit comments