@gswl/compose
v1.0.1
Published
``` const ctx = {}; const arr: number[] = []; const test = compose([ async (context, next) => { arr.push(1); arr.push(await next()); arr.push(11); },
Downloads
5
Readme
compose
const ctx = {};
const arr: number[] = [];
const test = compose([
async (context, next) => {
arr.push(1);
arr.push(await next());
arr.push(11);
},
async (context, next) => {
arr.push(2);
await delay(1000);
arr.push(12);
},
async (context, next) => {
arr.push(3);
return 9;
},
async (context, next) => {
arr.push(4);
arr.push(await next());
arr.push(14);
},
async (context, next) => {
arr.push(5);
arr.push(15);
return 7;
},
]);
const res = await test(ctx);
const chk = [1, 2, 12, 3, 4, 5, 15, 7, 14, 7, 11];
arr.forEach((a, i) => {
expect(a).to.be.equal(chk[i]);
});
expect(res).equal(7);