- commit
- 410024f
- parent
- 2c42194
- author
- Eric Bower
- date
- 2023-04-20 04:19:24 +0000 UTC
tweaks
1 files changed,
+3,
-3
+3,
-3
1@@ -32,18 +32,18 @@ export function compose<Ctx extends MdwCtx = MdwCtx>(
2
3 function* dispatch(i: number): Generator<Instruction, Result<T>, void> {
4 if (i <= index) {
5- throw new Error("next() called multiple times");
6+ return Err(new Error("next() called multiple times"));
7 }
8 index = i;
9 let fn: any = middleware[i];
10 if (i === middleware.length) fn = next;
11 if (!fn) return Err(new Error("fn is falsy"));
12 const nxt = dispatch.bind(null, i + 1);
13- const result = yield* call(() => fn(context, nxt));
14+ const result = yield* fn(context, nxt);
15 return result;
16 }
17
18- yield* dispatch(0);
19+ yield* call(() => dispatch(0));
20 return context;
21 };
22 }