Node.js 之async.js 里waterfall模块样例

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'); 
}); 

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/9fadb59ccd1ab3c4921a20dcca4438f7.html