Skip to content
This repository has been archived by the owner on Nov 27, 2023. It is now read-only.

Commit

Permalink
Fix groupByMap note
Browse files Browse the repository at this point in the history
  • Loading branch information
jridgewell committed Dec 14, 2021
1 parent 2c26f67 commit 7486980
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2407,7 +2407,7 @@ <h1><span class="secnum">2.2</span> Array.prototype.groupByMap ( <var>callbackfn
<p>When the <code>groupByMap</code> method is called with one or two arguments, the following steps are taken:</p>
<emu-alg><ol><li>Let <var>O</var> be ?&nbsp;<emu-xref aoid="ToObject" id="_ref_10"><a href="https://tc39.es/ecma262/#sec-toobject">ToObject</a></emu-xref>(<emu-val>this</emu-val> value).</li><li>Let <var>len</var> be ?&nbsp;<emu-xref aoid="LengthOfArrayLike" id="_ref_11"><a href="https://tc39.es/ecma262/#sec-lengthofarraylike">LengthOfArrayLike</a></emu-xref>(<var>O</var>).</li><li>If <emu-xref aoid="IsCallable" id="_ref_12"><a href="https://tc39.es/ecma262/#sec-iscallable">IsCallable</a></emu-xref>(<var>callbackfn</var>) is <emu-val>false</emu-val>, throw a <emu-val>TypeError</emu-val> exception.</li><li>Let <var>k</var> be 0.</li><li>Let <var>groups</var> be a new empty <emu-xref href="#sec-list-and-record-specification-type"><a href="https://tc39.es/ecma262/#sec-list-and-record-specification-type">List</a></emu-xref>.</li><li>Repeat, while <var>k</var> &lt; <var>len</var><ol><li>Let <var>Pk</var> be !&nbsp;<emu-xref aoid="ToString" id="_ref_13"><a href="https://tc39.es/ecma262/#sec-tostring">ToString</a></emu-xref>(<emu-xref href="#𝔽"><a href="https://tc39.es/ecma262/#𝔽">𝔽</a></emu-xref>(<var>k</var>)).</li><li>Let <var>kValue</var> be ?&nbsp;<emu-xref aoid="Get" id="_ref_14"><a href="https://tc39.es/ecma262/#sec-get-o-p">Get</a></emu-xref>(<var>O</var>, <var>Pk</var>).</li><li>Let <var>key</var> be ?&nbsp;<emu-xref aoid="Call" id="_ref_15"><a href="https://tc39.es/ecma262/#sec-call">Call</a></emu-xref>(<var>callbackfn</var>, <var>thisArg</var>, « <var>kValue</var>, <emu-xref href="#𝔽"><a href="https://tc39.es/ecma262/#𝔽">𝔽</a></emu-xref>(<var>k</var>), <var>O</var> »).</li><li>If <var>key</var> is <emu-val>-0</emu-val><sub>𝔽</sub>, set <var>key</var> to <emu-val>+0</emu-val><sub>𝔽</sub>.</li><li>Perform !&nbsp;<emu-xref aoid="AddValueToKeyedGroup" id="_ref_16"><a href="#sec-add-value-to-keyed-group">AddValueToKeyedGroup</a></emu-xref>(<var>groups</var>, <var>key</var>, <var>kValue</var>).</li><li>Set <var>k</var> to <var>k</var> + 1.</li></ol></li><li>Let <var>map</var> be !&nbsp;<emu-xref aoid="Construct" id="_ref_17"><a href="https://tc39.es/ecma262/#sec-construct">Construct</a></emu-xref>(<emu-xref href="#sec-map-constructor"><a href="https://tc39.es/ecma262/#sec-map-constructor">%Map%</a></emu-xref>).</li><li>For each <emu-xref href="#sec-list-and-record-specification-type"><a href="https://tc39.es/ecma262/#sec-list-and-record-specification-type">Record</a></emu-xref> { [[Key]], [[Elements]] } <var>g</var> of <var>groups</var>, do<ol><li>Let <var>elements</var> be !&nbsp;<emu-xref aoid="CreateArrayFromList" id="_ref_18"><a href="https://tc39.es/ecma262/#sec-createarrayfromlist">CreateArrayFromList</a></emu-xref>(<var>g</var>.[[Elements]]).</li><li>Let <var>entry</var> be the <emu-xref href="#sec-list-and-record-specification-type"><a href="https://tc39.es/ecma262/#sec-list-and-record-specification-type">Record</a></emu-xref> { [[Key]]: <var>g</var>.[[Key]], [[Value]]: <var>elements</var> }.</li><li>Append <var>entry</var> as the last element of <var>map</var>.[[MapData]].</li></ol></li><li>Return <var>map</var>.</li></ol></emu-alg>
<emu-note><span class="note">Note 2</span><div class="note-contents">
<p>The <code>groupBy</code> function is intentionally generic; it does not require that its <emu-val>this</emu-val> value be an Array object. Therefore it can be transferred to other kinds of objects for use as a method.</p>
<p>The <code>groupByMap</code> function is intentionally generic; it does not require that its <emu-val>this</emu-val> value be an Array object. Therefore it can be transferred to other kinds of objects for use as a method.</p>
</div></emu-note>
</emu-clause>

Expand Down
2 changes: 1 addition & 1 deletion spec.emu
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ location: https://tc39.es/proposal-array-grouping/
1. Return _map_.
</emu-alg>
<emu-note>
<p>The `groupBy` function is intentionally generic; it does not require that its *this* value be an Array object. Therefore it can be transferred to other kinds of objects for use as a method.</p>
<p>The `groupByMap` function is intentionally generic; it does not require that its *this* value be an Array object. Therefore it can be transferred to other kinds of objects for use as a method.</p>
</emu-note>
</emu-clause>

Expand Down

0 comments on commit 7486980

Please sign in to comment.