@fastly/js-compute
Version:
JavaScript SDK and CLI for building JavaScript applications on [Fastly Compute](https://www.fastly.com/products/edge-compute/serverless).
11 lines (10 loc) • 387 B
JavaScript
// From https://github.com/harmony7/js-async-pipeline
export async function pipeline(steps, initialValue, opts) {
let val = initialValue;
for (const [index, step] of steps.entries()) {
await opts?.beforeStep?.call(opts, val, index, steps);
val = await step(val, index, steps);
await opts?.afterStep?.call(opts, val, index, steps);
}
return val;
}