diff options
Diffstat (limited to 'cli/js/read_file.ts')
-rw-r--r-- | cli/js/read_file.ts | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/cli/js/read_file.ts b/cli/js/read_file.ts index 705720b05..31b0348e6 100644 --- a/cli/js/read_file.ts +++ b/cli/js/read_file.ts @@ -2,12 +2,13 @@ import { open, openSync } from "./files.ts"; import { readAll, readAllSync } from "./buffer.ts"; -/** Read the entire contents of a file synchronously. +/** Reads and returns the entire contents of a file. * * const decoder = new TextDecoder("utf-8"); * const data = Deno.readFileSync("hello.txt"); * console.log(decoder.decode(data)); - */ + * + * Requires `allow-read` permission. */ export function readFileSync(filename: string): Uint8Array { const file = openSync(filename); const contents = readAllSync(file); @@ -15,12 +16,13 @@ export function readFileSync(filename: string): Uint8Array { return contents; } -/** Read the entire contents of a file. +/** Reads and resolves to the entire contents of a file. * * const decoder = new TextDecoder("utf-8"); * const data = await Deno.readFile("hello.txt"); * console.log(decoder.decode(data)); - */ + * + * Requires `allow-read` permission. */ export async function readFile(filename: string): Promise<Uint8Array> { const file = await open(filename); const contents = await readAll(file); |