diff options
Diffstat (limited to 'cli/js/files.ts')
-rw-r--r-- | cli/js/files.ts | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/cli/js/files.ts b/cli/js/files.ts index 66a70f981..d3a4b5809 100644 --- a/cli/js/files.ts +++ b/cli/js/files.ts @@ -50,6 +50,9 @@ export async function open( * */ export function readSync(rid: number, p: Uint8Array): number | EOF { + if (p.length == 0) { + return 0; + } const nread = sendSyncMinimal(dispatch.OP_READ, rid, p); if (nread < 0) { throw new Error("read error"); @@ -70,6 +73,9 @@ export function readSync(rid: number, p: Uint8Array): number | EOF { * const text = new TextDecoder().decode(buf); */ export async function read(rid: number, p: Uint8Array): Promise<number | EOF> { + if (p.length == 0) { + return 0; + } const nread = await sendAsyncMinimal(dispatch.OP_READ, rid, p); if (nread < 0) { throw new Error("read error"); |