Ambiguity when async.auto provides an array
See original GitHub issueWhen step A in an async.auto
calls back with more than two arguments, a subsequent step B is shown an array as the result of step A. As far as I can tell, there is no way to distinguish (1) step A calling back in the usual way with an array, and (2) step A calling back with more than two arguments.
For example:
async.auto(
{
"stepA": function(cb) {
cb(null, 1, 2);
},
"stepB": [
"stepA",
function(cb, result) {
console.log(result.stepA); // [1, 2]
}
]
}
);
async.auto(
{
"stepA": function(cb) {
cb(null, [1, 2]);
},
"stepB": [
"stepA",
function(cb, result) {
console.log(result.stepA); // [1, 2]
}
]
}
);
If your auto
step normally calls back with an array, but the oddball third argument is optional, I’m not sure there’s a robust way to tell if the third argument is present.
It does seem natural for auto
to deal with more than one argument by providing an array, but maybe it should do something to resolve this ambiguity. For example, it could tag the array with a special property.
I realize that 2.0 has some changes to auto
but, as far as I could tell, this particular issue is still present.
Issue Analytics
- State:
- Created 7 years ago
- Comments:10 (4 by maintainers)
Top GitHub Comments
I published this on npm as callpack. The download numbers suggest that it has at least 10 users over the past two weeks.
I think we can rely on newer language features to smooth this over: