-
Notifications
You must be signed in to change notification settings - Fork 17
Static method naming #57
Comments
There’s no clear precedent for this - Promise.all and friends produce a Promise, Object.fromEntries and Object.create produce an Object, Array.from produces an Array. However, Object.keys/values/entries/getOwnPropertyDesceiptor etc operate on an Object. |
I think having the name |
The recognisability of the name does sound very valuable. So like |
How about |
@nickmccurdy This method is the opposite of that - your data is not grouped yet, and you want it to be. |
I was thinking of it more from the mathematical perspective, where the callback is a functor mapping an ungrouped collection to a grouped collection. Though if the result is too arbitrary, maybe |
“fromX” means it’s an X already, and as you said, it’s ungrouped. |
@nickmccurdy correct me if I'm wrong, but @ljharb I think what @nickmccurdy is suggesting is that |
Functions are verbs, so that function could be a "grouper" but wouldn't be "groups", a noun - and |
I try to avoid putting |
TC39 reaffirmed consensus today on the existing |
With the new static based functions. I was wondering if there were alternatives to the
groupBy
name.Object.groupBy
andMap.groupBy
sounds a little like it operates onObject
orMap
as opposed to building them.Background
The majority of static
Object
methods operate on an object argument:The static
Object
methods that create an object,Object.create
andObject.fromEntries
, are in the minority but use words that strongly convey that a new value is being created.Suggestions
Some alternatives we came up with at Bloomberg:
Object.byGrouping
Object.fromGrouping
Object.groupFrom
Thoughts?
The text was updated successfully, but these errors were encountered: