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

Function readJavaScript

src/javascript/module.ts:231–242  ·  view source on GitHub ↗
(sourcePath: string)

Source from the content-addressed store, hash-verified

229}
230
231export async function readJavaScript(sourcePath: string): Promise<string> {
232 const source = await readFile(sourcePath, "utf-8");
233 switch (extname(sourcePath)) {
234 case ".ts":
235 return transformJavaScript(source, "ts", sourcePath);
236 case ".jsx":
237 return transformJavaScript(source, "jsx", sourcePath);
238 case ".tsx":
239 return transformJavaScript(source, "tsx", sourcePath);
240 }
241 return source;
242}
243
244export function readJavaScriptSync(sourcePath: string): string {
245 const source = readFileSync(sourcePath, "utf-8");

Callers 2

PreviewServerClass · 0.85
buildFunction · 0.85

Calls 1

transformJavaScriptFunction · 0.85

Tested by

no test coverage detected