mirror of
https://github.com/weaveworks/scope.git
synced 2026-07-18 12:59:31 +00:00
17 lines
272 B
JavaScript
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);
|
|
}
|