は編集:
async.waterfall([
one,
two,
], function (err, result) {
// result now equals null
});
function one(cb) {
cb(null, null);
}
function two(arg1, cb) {
cb(null, arg1);
}
そしてデモでそれを試してみてください。
async.waterfall([
function(callback) {
callback(null, 'one', 'two');
},
function(arg1, arg2, callback) {
// arg1 now equals 'one' and arg2 now equals 'two'
callback(null, 'three');
},
function(arg1, callback) {
// arg1 now equals 'three'
callback(null, 'done');
}
], function (err, result) {
// result now equals 'done'
});
//あるいは、名前付き関数:
async.waterfall([
myFirstFunction,
mySecondFunction,
myLastFunction,
], function (err, result) {
// result now equals 'done'
});
function myFirstFunction(callback) {
callback(null, 'one', 'two');
}
function mySecondFunction(arg1, arg2, callback) {
// arg1 now equals 'one' and arg2 now equals 'two'
callback(null, 'three');
}
function myLastFunction(arg1, callback) {
// arg1 now equals 'three'
callback(null, 'done');
}
とで続きを読む、Link
こんにちは男に続きを読む:https://caolan.github.io/async/docs.html – anhlee