diff options
Diffstat (limited to 'js/read_file.ts')
-rw-r--r-- | js/read_file.ts | 40 |
1 files changed, 20 insertions, 20 deletions
diff --git a/js/read_file.ts b/js/read_file.ts index 288841672..3aeedec28 100644 --- a/js/read_file.ts +++ b/js/read_file.ts @@ -4,26 +4,6 @@ import * as flatbuffers from "./flatbuffers"; import { assert } from "./util"; import * as dispatch from "./dispatch"; -/** Read the entire contents of a file synchronously. - * - * const decoder = new TextDecoder("utf-8"); - * const data = Deno.readFileSync("hello.txt"); - * console.log(decoder.decode(data)); - */ -export function readFileSync(filename: string): Uint8Array { - return res(dispatch.sendSync(...req(filename))); -} - -/** Read the entire contents of a file. - * - * const decoder = new TextDecoder("utf-8"); - * const data = await Deno.readFile("hello.txt"); - * console.log(decoder.decode(data)); - */ -export async function readFile(filename: string): Promise<Uint8Array> { - return res(await dispatch.sendAsync(...req(filename))); -} - function req( filename: string ): [flatbuffers.Builder, msg.Any, flatbuffers.Offset] { @@ -44,3 +24,23 @@ function res(baseRes: null | msg.Base): Uint8Array { assert(dataArray != null); return new Uint8Array(dataArray!); } + +/** Read the entire contents of a file synchronously. + * + * const decoder = new TextDecoder("utf-8"); + * const data = Deno.readFileSync("hello.txt"); + * console.log(decoder.decode(data)); + */ +export function readFileSync(filename: string): Uint8Array { + return res(dispatch.sendSync(...req(filename))); +} + +/** Read the entire contents of a file. + * + * const decoder = new TextDecoder("utf-8"); + * const data = await Deno.readFile("hello.txt"); + * console.log(decoder.decode(data)); + */ +export async function readFile(filename: string): Promise<Uint8Array> { + return res(await dispatch.sendAsync(...req(filename))); +} |