-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Consider changing minWith
and maxWith
APIs to be more like sortBy
#65
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
+1 |
Fixed in c1c986b |
I think this should this be done with |
i'm changing my mind on this. what if the objects in the list you are evaluating have complicated relations? e.g. |
EDIT: this was in response to @megawac's comment, not @buzzdecafe's. I'm not so sure about that. I can easily see:
This can't necessarily be captured by a single key. |
Some other libraries allow you to return an array from these functions which will compare in order. |
@buzzdecafe: I agree regarding uniqWith, et al. But I can't see any use cases for |
i was also thinking |
@buzzdecafe I'm also not sure that your example makes real sense, as I think all of these comparisons really need to be symmetric in the two parameters. But the general point stands. But yes, use |
I think the objection stands for |
@megawac Don't understand about the array. I'm mostly ok with |
Would give you the same functionality from a
|
@megawac Got it; thought you were talking ascending vs descending. I'd rather not go there. If we get as complicated as that, I'd rather just let 'em use an arbitrary function. |
Alright, it might be worth creating a |
@buzzdecafe I like a more general
(untested, and don't know if we actually have |
@megawac I agree, and it should be easy to implement the |
@CrossEye that example seems like a btw, gotta come up with a new name for |
@buzzdecafe |
at present |
Yeah, that's a different beast, isn't it? I've been thinking about |
I disagree @buzzdecafe, I think a |
@megawac Yes, the trouble is that it would be nice if we could have a universal semantic for the |
It wouldn't be hard to mix that in with an iterator |
since |
let's rename |
@megawac: We've been trying to avoid any unnecessary type-checking, making our functions as strongly-typed as feasible in JS. We definitely aren't interested in the Underscore/LoDash style of "if parameter 3 is a function do x, if it's an object, do y, and if it's a string do z." This is not to say that we have no type-checking, but there's relatively little, and that's mostly to support dynamic dispatch for extensions, such as the lazy lists, and (soon, I hope) the algebraic types. @buzzdecafe That might be best. But can't think of a good name. |
@buzzdecafe That sounds good. |
The original goal of this issue was long ago satisfied. If we want to follow up on the remaining discussion, we can reopen later. |
sortBy
has a nicer API than dominWith
andmaxWith
.In
sortBy
we generate a key for the objects to sort, and the comparator to use is automatically created based on this key. So we can do something as simple asminWith
andmaxWith
, by contrast, which don't even need to be sorted, require you to supply a comparator.This really should be
Granted the current API offers some theoretic additional flexibility. But I can't see any realistic cases that would take advantage of it.
If there are no objections, I'll do this over the weekend.
The text was updated successfully, but these errors were encountered: