Extract Args from a val

await @pomdtr.extractValArgs("pomdtr.extractValArgs")
// [{ "name": "val", "type": "string" }]

Why ?

Just an example of doing some static analysis.

Using this approach to generate a json schema of a val input would be nice.

Readme
1
2
3
4
5
6
7
8
9
10
import { extractArgs } from "https://esm.town/v/pomdtr/extractArgs";
import { valToString } from "https://esm.town/v/pomdtr/valToString";
export async function extractValArgs(val: string) {
const code = await valToString(val);
return extractArgs(code) as Promise<{
name: string;
type: string;
}[]>;
}
👆 This is a val. Vals are TypeScript snippets of code, written in the browser and run on our servers. Create scheduled functions, email yourself, and persist small pieces of data — all from the browser.