Loading homepage
Compose asynchronous middleware into a reusable pipeline with downstream execution and reverse-order unwinding.
Input: const run = compose([ async (ctx, next) => { ctx.push("before"); await next(); ctx.push("after"); }, async (ctx) => { ctx.push("middle"); }, ]); const log = []; await run(log); Output: log is ["before", "middle", "after"].
Input: await compose([])({}, async () => "done"); Output: "done"
Implement the exported function in index.js or index.ts. Tests provide fixtures for the required behavior.