slige/web/public/src/data.ts

32 lines
744 B
TypeScript

export type FlameGraphNode = {
fn: number;
acc: number;
parent: number;
children: FlameGraphNode[];
};
export async function flameGraphData(): Promise<FlameGraphNode> {
return await fetch("/api/flame-graph")
.then((v) => v.json())
.then((v) => v.flameGraph);
}
export async function codeData(): Promise<string> {
return await fetch("/api/source")
.then((v) => v.json())
.then((v) => v.text);
}
export type CodeCovEntry = {
index: number;
line: number;
col: number;
covers: number;
};
export async function codeCoverageData(): Promise<CodeCovEntry[]> {
return await fetch("/api/code-coverage")
.then((v) => v.json())
.then((v) => v.codeCoverage);
}