diff options
Diffstat (limited to '')
| -rw-r--r-- | src/util.ts | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/util.ts b/src/util.ts index 136815e..13bdb35 100644 --- a/src/util.ts +++ b/src/util.ts @@ -1,4 +1,15 @@ +import { Type } from "ts-morph" +import { Ctx } from "./types" + export const match = <K extends string, R>( k: K | undefined, pattern: { [key in K | '_']: () => R } ) => (k && pattern[k] ? pattern[k]() : pattern._()) + +export const evalList = async (ctx: Ctx, effectTyps: Type[]) => { + const effectResults: string[] = [] + for (const item of effectTyps ?? []) { + effectResults.push(...(await ctx.evaluateType(ctx, item))) + } + return effectResults +} |
