proposal-record-tuple icon indicating copy to clipboard operation
proposal-record-tuple copied to clipboard

initial pass of Tuple group/groupToMap for proposal-array-grouping

Open rickbutton opened this issue 3 years ago • 0 comments

This PR represents a first pass addition of Tuple.prototype.group and Tuple.prototype.groupToMap, reflecting the addition of similar methods to the Array.prototype in https://github.com/tc39/proposal-array-grouping .

The array grouping proposal is currently at Stage 3, so we don't intend to merge this until Array Grouping reaches Stage 4, but want to prepare this in case it advanced ahead of Records and Tuples.

A few notes on this spec text:

  • This is almost entirely the same as the spec text for regular Array versions of these methods, which some verbiage changed to refer to Tuple.
  • This relies on the AO AddValueToKeyedGroup that the array grouping proposal implements, so if you are looking for that it is here: https://tc39.es/proposal-array-grouping/#sec-add-value-to-keyed-group
  • I removed the comments ahead of the algorithm steps regarding the mutation of the Array (Tuple) being traversed, as they don't apply here, since Tuples are immutable.
  • The return value of both of these new methods is an Object of Arrays. This choice was made so that a symbol can be used as a "grouping key" (because a Record cannot have a symbol key, see the discussion in this issue: https://github.com/tc39/proposal-record-tuple/issues/275#issuecomment-995834454)

rickbutton avatar Jul 08 '22 16:07 rickbutton