Files
weave-scope/client/app/scripts/utils/async-utils.js
2017-01-16 15:25:20 -08:00

17 lines
272 B
JavaScript

export function waterfall(series, target, cb) {
function next(result) {
const fn = series.shift();
if (fn) {
try {
fn(result, next);
} catch (e) {
cb(e);
}
} else {
cb(null, result);
}
}
next(target, next);
}