Skip to content

Instantly share code, notes, and snippets.

@aisk
Last active August 29, 2015 14:17
Show Gist options
  • Save aisk/a1be64b2b21d81793114 to your computer and use it in GitHub Desktop.
Save aisk/a1be64b2b21d81793114 to your computer and use it in GitHub Desktop.
'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);
});
@sdjcw
Copy link

sdjcw commented Mar 26, 2015

例子有问题吧。。。
let_it_bug 是 true,第一次调用走的是 12 13 行,cb 回调是没有任何参数的,所以 21 行的参数应该就只有 cb 一个。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment