blob: 13bdb35b85a3f3d8275572582ce0baeb90ff016d (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
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
}
|