Closed esusatyo closed 8 years ago
I like the idea of supporting the group by API, but I think the API you are proposing doesn't exactly fit with the rest of the API.
Underscore.groupBy(NSArray *source, id key)
seems like something that would feel more at home here or the chained vision would be: Underscore.array(names).groupBy(@"sex").unwrap
Just my 2 cents.
I think a problem with this is that you have to assume the elements are NSDictionary
objects though. You would have to handle the more general case for this to work.
Maybe if the groupBy parameter were an NSPredicate
.
I have just found this commit while trying to make this: https://github.com/robb/Underscore.m/commit/c5c33c60840a2eaa38dbae214bb4bc84a143b398. So @akitsukada tried adding this and we haven't had any version release since then.
I'm testing their implementation right now, and if it's suitable for our need, I might just send a request to do a release from the current development branch.
Yeah, I'm not sure this project is getting a lot of attention. I've asked the owner if he's interested in letting someone else take it over. But no reply just yet. If I don't get any response I might just start a fork very soon.
@khendry I've made you a collaborator, feel free to cut a new release :bow:
Cool! Thanks.
Group By will be included in the next release.
Say I have this array of dictionaries:
The command
names.group_by(@"sex")
will return the array grouped by the sex.I think this may be possible to do right now by chaining, but would be good to have this added to the main methods in
Underscore+Functional.h