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

Allow every and filter callbacks to receive errors as first argument #118

Closed
bwindels opened this issue Mar 27, 2012 · 6 comments
Closed

Comments

@bwindels
Copy link

The fact that the callbacks for the every and filter functions don't accept an error object can be restrictive in some situations. For example when you do I/O operations in the iterator, you might want to differentiate between an I/O error and a result that got filtered in the final callback. Right now the API does not allow you to differentiate between the two cases.

I understand that these functions were designed this way because of certain nodejs API (path.exists), but maybe we could have alternative versions of these functions (everyWithError, filterWithError) or have smart behavior that can handle both cases. The latter solution would consider the first argument of the callback to be an error only if two arguments were passed. That error would be passed to the final callback as the first argument as well, as happens with the other functions.

I might try to write a patch for the last solution sometime soon.

@LabiKyo
Copy link

LabiKyo commented May 12, 2013

+1, I need that too

@caolan
Copy link
Owner

caolan commented May 13, 2013

I agree this would be nice to add but it is backwards incompatible, the hard part is managing the release not writing the code, and I keep putting it off ;)

@gyllstromk
Copy link

I have a code proposal for this here: PopCometLabs@2aa2f82

It uses a new function name to avoid backward compatibility collisions.

I'll submit a PR if this works for you.

@aearly
Copy link
Collaborator

aearly commented May 19, 2015

This issue got closed in a bulk update.

I agree that it is odd that an async function would return a boolean as the first argument. The only core API method that does this is fs.exists, and it is becoming deprecated.

We should change this when we are doing a breaking release to expect an function (err, bool) {} callback, and maybe provide a wrapper for backwards compatibility.

@kobezzza
Copy link

+1

@LinusU
Copy link

LinusU commented Aug 10, 2015

Could this be added to the 2.0 milestone? Would love to see this resolved 👍

@aearly aearly added this to the 2.0 milestone Oct 25, 2015
This was referenced Feb 24, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants