diff options
author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2020-07-19 19:49:44 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-07-19 19:49:44 +0200 |
commit | fa61956f03491101b6ef64423ea2f1f73af26a73 (patch) | |
tree | c3800702071ca78aa4dd71bdd0a59a9bbe460bdd /cli/js/ops/io.ts | |
parent | 53adde866dd399aa2509d14508642fce37afb8f5 (diff) |
Port internal TS code to JS (#6793)
Co-authored-by: Ryan Dahl <ry@tinyclouds.org>
Diffstat (limited to 'cli/js/ops/io.ts')
-rw-r--r-- | cli/js/ops/io.ts | 50 |
1 files changed, 0 insertions, 50 deletions
diff --git a/cli/js/ops/io.ts b/cli/js/ops/io.ts deleted file mode 100644 index 355a09ae0..000000000 --- a/cli/js/ops/io.ts +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. - -import { sendAsyncMinimal, sendSyncMinimal } from "./dispatch_minimal.ts"; - -export function readSync(rid: number, buffer: Uint8Array): number | null { - if (buffer.length === 0) { - return 0; - } - - const nread = sendSyncMinimal("op_read", rid, buffer); - if (nread < 0) { - throw new Error("read error"); - } - - return nread === 0 ? null : nread; -} - -export async function read( - rid: number, - buffer: Uint8Array, -): Promise<number | null> { - if (buffer.length === 0) { - return 0; - } - - const nread = await sendAsyncMinimal("op_read", rid, buffer); - if (nread < 0) { - throw new Error("read error"); - } - - return nread === 0 ? null : nread; -} - -export function writeSync(rid: number, data: Uint8Array): number { - const result = sendSyncMinimal("op_write", rid, data); - if (result < 0) { - throw new Error("write error"); - } - - return result; -} - -export async function write(rid: number, data: Uint8Array): Promise<number> { - const result = await sendAsyncMinimal("op_write", rid, data); - if (result < 0) { - throw new Error("write error"); - } - - return result; -} |