reads and returns binary data from a file on supported runtimes (i.e. RUNTIME.DENO, RUNTIME.BUN, or RUNTIME.NODE). for unsupported runtimes, an error is thrown.
an error is thrown if an unsupported runtime uses this function.
import { assertInstanceOf, assertStringIncludes } from "jsr:@std/assert"const my_deno_json_bytes = await readFile(identifyCurrentRuntime(), new URL(import.meta.resolve("../deno.json")))assertInstanceOf(my_deno_json_bytes, Uint8Array)const my_deno_json = (new TextDecoder()).decode(my_deno_json_bytes)assertStringIncludes(my_deno_json, `"name": "@oazmi/kitchensink"`) Copy
import { assertInstanceOf, assertStringIncludes } from "jsr:@std/assert"const my_deno_json_bytes = await readFile(identifyCurrentRuntime(), new URL(import.meta.resolve("../deno.json")))assertInstanceOf(my_deno_json_bytes, Uint8Array)const my_deno_json = (new TextDecoder()).decode(my_deno_json_bytes)assertStringIncludes(my_deno_json, `"name": "@oazmi/kitchensink"`)
the runtime enum indicating which runtime should be used for reading the filesystem.
the source file path to read from.
provide optional configuration on how the reading should be performed.
reads and returns binary data from a file on supported runtimes (i.e. RUNTIME.DENO, RUNTIME.BUN, or RUNTIME.NODE). for unsupported runtimes, an error is thrown.
Throws
an error is thrown if an unsupported runtime uses this function.
Example