@gswl/compose
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

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);

Readme

Keywords

none

Package Sidebar

Install

npm i @gswl/compose

Weekly Downloads

0

Version

1.0.1

License

ISC

Unpacked Size

3.01 kB

Total Files

4

Last publish

Collaborators

  • gswlwp