Skip to content
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

Reduce with governor, without initial value #5

Open
kriskowal opened this issue Jul 29, 2024 · 2 comments
Open

Reduce with governor, without initial value #5

kriskowal opened this issue Jul 29, 2024 · 2 comments

Comments

@kriskowal
Copy link
Member

Array.prototype.reduce is sensitive to call arity, to detect whether to begin with a base value or wait for the first iteration result. So, the governor argument forces the arity high enough to compel the interpretation of an undefined base result.

  • Should AsyncIterator.prototype.reduce be insensitive to arity, defaulting the basis to undefined? In this world, governor can be a third positional argument without issue.
  • Should AsyncIterator.prototype.reduce be sensitive to arrity, always interpreting the presence of a governor as consent to treat the second argument as a basis.
  • Should AsyncIterator.prototype have a separate method; e.g., reduceWithGovernor, governedReduce, or produce; that accepts a governor and optional basis?
@kriskowal
Copy link
Member Author

It occurs to me that reduce with a basis and governor is very different than (say) merge with only a governor, so separate methods may make a lot of sense. I will try to find some time to elaborate (or connect with your prior reasoning)

@kriskowal
Copy link
Member Author

Specifically, when there is a basis and concurrency, it makes sense for that basis be used to prime every concurrent job, both initially and whenever concurrency increases. When there is no basis, it only make sense for each job to draw a basis from the source. Regardless of order preservation, neither guarantees the order of merges, just that the ordered versions only merge adjacent values from the source stream, and that the basis might be interpolated between any of them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant