From 4d4908dde31316462acae5caec8dfcbbf7a244bd Mon Sep 17 00:00:00 2001 From: Alexandre Szymocha Date: Sat, 28 Dec 2019 14:48:36 +0100 Subject: Fix: allow reading into a 0-length array (#3329) --- cli/js/io.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'cli/js/io.ts') diff --git a/cli/js/io.ts b/cli/js/io.ts index 15a4ad09b..4ca5289d1 100644 --- a/cli/js/io.ts +++ b/cli/js/io.ts @@ -18,12 +18,14 @@ export enum SeekMode { // https://golang.org/pkg/io/#Reader export interface Reader { /** Reads up to p.byteLength bytes into `p`. It resolves to the number - * of bytes read (`0` < `n` <= `p.byteLength`) and rejects if any error encountered. + * of bytes read (`0` <= `n` <= `p.byteLength`) and rejects if any error encountered. * Even if `read()` returns `n` < `p.byteLength`, it may use all of `p` as * scratch space during the call. If some data is available but not * `p.byteLength` bytes, `read()` conventionally returns what is available * instead of waiting for more. * + * When `p.byteLength` == `0`, `read()` returns `0` and has no other effects. + * * When `read()` encounters end-of-file condition, it returns EOF symbol. * * When `read()` encounters an error, it rejects with an error. -- cgit v1.2.3