MCPcopy Create free account
hub / github.com/observablehq/framework / transpileCode

Function transpileCode

src/preview.ts:483–487  ·  view source on GitHub ↗
({id, node, mode}: MarkdownCode, resolvers: Resolvers, params?: Params)

Source from the content-addressed store, hash-verified

481// changes, the sha is already included in the transpiled code, and hence will
482// likewise be re-evaluated.
483function transpileCode({id, node, mode}: MarkdownCode, resolvers: Resolvers, params?: Params): string {
484 const hash = createHash("sha256");
485 for (const f of node.files) hash.update(resolvers.resolveFile(f.name));
486 return `${transpileJavaScript(node, {id, mode, params, ...resolvers})} // ${hash.digest("hex")}`;
487}
488
489function getFiles({files, resolveFile}: Resolvers): Map<string, string> {
490 return new Map(Array.from(files, (f) => [f, resolveFile(f)]));

Callers 1

getCodeFunction · 0.85

Calls 2

resolveFileMethod · 0.80
transpileJavaScriptFunction · 0.70

Tested by

no test coverage detected