Last active
August 29, 2015 14:17
-
-
Save aisk/a1be64b2b21d81793114 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
var async = require('async'); | |
var let_it_bug = true; | |
var ioFunc = function(cb) { | |
if (! let_it_bug) { | |
var result = 42; // do something to get the result | |
cb(undefined, 42); | |
} else { | |
var result = undefined; // do something to get the result | |
cb(); // because result is undefined, I usually call the callback without parameters, let them be undefined | |
} | |
}; | |
async.waterfall([ | |
function(cb) { | |
ioFunc(cb); | |
}, | |
function(data, cb) { | |
cb(undefined, data); | |
}, | |
], function(err, data) { | |
console.log(arguments); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
例子有问题吧。。。
let_it_bug 是 true,第一次调用走的是 12 13 行,cb 回调是没有任何参数的,所以 21 行的参数应该就只有 cb 一个。