歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux編程 >> Linux編程 >> Node.js 之async.js 裡waterfall模塊樣例

Node.js 之async.js 裡waterfall模塊樣例

日期:2017/3/1 10:05:41   编辑:Linux編程

Node.js 之async.js 裡waterfall模塊樣例

/**
* Created with JetBrains WebStorm.
* User: hexie
* Date: 12-12-6
* Time: 上午9:58
* To change this template use File | Settings | File Templates.
*/

var async = require('async');

async.waterfall([
function(callback){
callback(null, 'one', 'two');
console.log('1');
},
function(arg1, arg2, callback){
callback(null, 'three');
console.log(arg1);
console.log(arg2);
},
function(arg1, callback){
// arg1 now equals 'three'
callback(null, 'done');
console.log(arg1);
}
], function (err, result) {
console.log(result);
// result now equals 'done'
// console.log('4');
});

Copyright © Linux教程網 All Rights Reserved