-
Notifications
You must be signed in to change notification settings - Fork 621
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
feat(collections): add sumOf #1108
Conversation
Edit: As I understand it, |
Edit: Actually, I'm not really sure how to implement this. as I cant get typescript to really agree since the selector would be a union type and it doesn't like adding that to |
Would have to make it generic:
Keep in mind that you can't add a number and a bigint. You'll have to explicitly convert or get a runtime error. |
As the type is determined by the selector, you could probably use S extends (el: T) => number | (el: T) => bigint as the type for The only problem is the empty input case - it needs to return |
I don't think I'll be implementing bigint support in this PR as I don't know how to implement it type wise and the actual implementation would be scuffed enough that it'd just be wasteful in terms of memory and performance. @LionC @caspervonb But other than that I think it's good to go |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@grian32 LGTM. I think this is enough for the first pass. Thank you for your contribution!
With regard to bigint support, how about providing explicit option or alternative function?
|
I think this is actually the only way to do this with the current signature - I do not see how we can decide which That is something for another day then :-) Thank you a lot @grian32 , good work! |
Not sure if there should be more tests, couldn't really think of anything else as its a pretty simple function.
Related: #1065