Comments (11)
I think having the name groupBy
is important for recognizability (our own ecosystem precedent and from other languages). I don't think there's a clear pattern for naming factory methods.
from proposal-array-grouping.
“fromX” means it’s an X already, and as you said, it’s ungrouped.
from proposal-array-grouping.
TC39 reaffirmed consensus today on the existing groupBy
name.
from proposal-array-grouping.
The recognisability of the name does sound very valuable. So like {_,Lodash,Ramda}.groupBy
, in this situation the namespace should be seen as a general collection of utilities. And having Array.groupBy
doesn't scale as nicely to having various different collection types.
from proposal-array-grouping.
@nickmccurdy This method is the opposite of that - your data is not grouped yet, and you want it to be.
from proposal-array-grouping.
Functions are verbs, so that function could be a "grouper" but wouldn't be "groups", a noun - and fromGrouper
sounds like it's a fish :-)
from proposal-array-grouping.
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.
from proposal-array-grouping.
How about fromGroups
? It aligns with existing static methods like Array.fromAsync
.
from proposal-array-grouping.
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 fromGrouping
would be more clear.
from proposal-array-grouping.
@nickmccurdy correct me if I'm wrong, but @ljharb I think what @nickmccurdy is suggesting is that groups
is referring to the function that converts from "ungrouped" to "grouped". An expansion of the name could be: getGroupsFromGroups
and when you consider the "more clear" version he provided: fromGrouping
, this makes even more sense: getGroupsFromGrouping
.
from proposal-array-grouping.
I try to avoid putting get
in function names as it's usually already obvious. Maybe just groups
or grouped
could work? Though I'm not sure if they'd have naming collisions.
from proposal-array-grouping.
Related Issues (20)
- don't prefer Object over Map HOT 21
- Add the new method names to Array.prototype [ @@unscopables ]
- Supporing Records/Tuples and Maps HOT 4
- Web Compatibility Issue: Sugar versions v0.9 through v1.3.9 (inclusive) HOT 27
- TypedArray support? HOT 1
- Should HasProperty be called, the same way Array.prototype.map calls it? HOT 3
- `group` and `groupToMap` why not merge into one api HOT 6
- WebCompat regressions with `group` HOT 37
- Why not let the user provide a second argument to control how the values accumulate against a key? HOT 3
- Consider alternative attachment on Object and Map HOT 3
- with target object HOT 5
- How to convert array of of objects to a hash? HOT 2
- How to convert an array of of objects to a hash? HOT 10
- Grouping via iterator methods? HOT 11
- How about add `groupToArray` or `chunk`? HOT 3
- Stage 3 Criteria HOT 10
- Subclassing HOT 7
- Stage 4 Criteria HOT 7
- Request to reconsider `groupBy` as a prototype function HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from proposal-array-grouping.