MCPcopy Create free account
hub / github.com/denoland/std / readFile

Function readFile

fs/unstable_read_file.ts:27–42  ·  view source on GitHub ↗
(
  path: string | URL,
  options?: ReadFileOptions,
)

Source from the content-addressed store, hash-verified

25 * @returns A promise that resolves to a `Uint8Array` of the file contents.
26 */
27export async function readFile(
28 path: string | URL,
29 options?: ReadFileOptions,
30): Promise<Uint8Array> {
31 if (isDeno) {
32 return Deno.readFile(path, { ...options });
33 } else {
34 const { signal } = options ?? {};
35 try {
36 const buf = await getNodeFs().promises.readFile(path, { signal });
37 return new Uint8Array(buf.buffer, buf.byteOffset, buf.length);
38 } catch (error) {
39 throw mapError(error);
40 }
41 }
42}
43
44/**
45 * Synchronously reads and returns the entire contents of a file as an array

Callers 6

resolveFunction · 0.85

Calls 2

getNodeFsFunction · 0.90
mapErrorFunction · 0.90

Tested by

no test coverage detected