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

reduceRight docs say takes object|array; only supports array #1232

Closed
megawac opened this issue Jul 12, 2016 · 3 comments
Closed

reduceRight docs say takes object|array; only supports array #1232

megawac opened this issue Jul 12, 2016 · 3 comments
Milestone

Comments

@megawac
Copy link
Collaborator

megawac commented Jul 12, 2016

Because reduceRight calls Array.prototype.slice on the passed in collection it only supports Arrays

This begs the question, is reversing an object really a good pattern? How about an iterator? If yes, should implement eachRight, eachOfRight and friends?

Also should we document Iterable support on all methods supporting iterators? Currently we only state we support Array | Object in these cases.

@megawac megawac added this to the 2.0 milestone Jul 12, 2016
@aearly
Copy link
Collaborator

aearly commented Jul 12, 2016

If you were using an iterator with reduceRight, you'd have to expand it into an array, e.g. async.reduceRight([...iterator], iteratee, cb). If your collection offered some sort of reverse iterator, you'd use that instead. Reversing the keys of an Object is mostly meaningless. I think it's fine if reduceRight only works with arrays.

@megawac
Copy link
Collaborator Author

megawac commented Jul 12, 2016

Okay, second part. Should each*, eachOf, map*, filter*, and friends be documented to take Iterables?

@aearly
Copy link
Collaborator

aearly commented Jul 12, 2016

Ah, yes.

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

No branches or pull requests

2 participants