-
Notifications
You must be signed in to change notification settings - Fork 147
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
wrapCallback and callbacks with more than two arguments #246
Comments
I agree that it would be good to support callbacks with multiple parameters, and it's easy enough to implement, but I think it feels a bit weird to emit single values in some cases and arrays in others. We might end up in a case where a callback is called with a different number of arguments at different times, and that would get hard to abstract over. Perhaps a _.wrapCallbackN = function(fn, n) {
return _.wrapCallback(function(...args, cb) {
fn(...args, function(e, ...results) {
cb(e, ensureArrayLength(n, results));
});
});
} (Note that, unlike other cases such as |
Isn't this the same problem that the EventEmitter Stream constructor had? Maybe that code can be reused? |
Ah, good find. Adding p.s. We usually avoid optional parameters, because they don't work with currying, but since this is a constructor function, not a stream method, that doesn't apply here (unless anyone disagrees!) |
⇒ #247 |
Thanks, @quarterto! |
Reopening until #247 is merged. |
Please consider solving #334 with mappingHint. |
@quarterto, you you have time to finish up #247? |
Wow, sorry, that totally slipped off my radar. I'll have a look this afternoon. |
Hi,
Why does wrapCallback ignore the third argument if there is one?
Wouldn't it be easy to check if there are more than two arguments and if so to put an array of these arguments into the stream?
Best regards,
Daniel
The text was updated successfully, but these errors were encountered: