-
Notifications
You must be signed in to change notification settings - Fork 590
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 runningReduce
#1226
feat (collections): add runningReduce
#1226
Conversation
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.
Thanks for implementing this! Loos good, I just added naming and API comments for consistency with the module. I really like the implementation.
collections/running_reduce.ts
Outdated
initialValue: A, | ||
): A[] { | ||
let _initialValue = initialValue; | ||
return collection.map((el) => _initialValue = reducer(_initialValue, el)); |
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.
This is actually pretty smart!
I would personally put the function body on a newline, as a lot of things are happening here, the line is hard enough to read as it is and it hides a statements in there.
return collection.map((el) => _initialValue = reducer(_initialValue, el)); | |
return collection.map((el) => | |
_initialValue = reducer(_initialValue, el) | |
); |
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.
When I apply this change, it doesn't seem to pass the deno fmt
check.
@LionC |
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.
LGTM! Pinging @kt3k
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.
last part of #1173