blob: f7bb20ad0e36db34459fbd1dbc36127e824d2f73 (
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
}
|