summaryrefslogtreecommitdiff
path: root/std/io/bufio.ts
diff options
context:
space:
mode:
authorRobert Jack Will <matey-jack@users.noreply.github.com>2019-10-28 18:28:29 +0100
committerBert Belder <bertbelder@gmail.com>2019-10-28 10:28:29 -0700
commitff9df0c321eb56c7f89f5ccdaa301453f22f708e (patch)
tree1e7c3363ebb61a45583ffe6b27bdd3de53c7fc65 /std/io/bufio.ts
parentb273989446d62808f922280247604431d1d219cb (diff)
std: fix BufReader.readString to actually return Deno.EOF at end (#3191)
Diffstat (limited to 'std/io/bufio.ts')
-rw-r--r--std/io/bufio.ts6
1 files changed, 3 insertions, 3 deletions
diff --git a/std/io/bufio.ts b/std/io/bufio.ts
index 213870c3c..b287ef3c1 100644
--- a/std/io/bufio.ts
+++ b/std/io/bufio.ts
@@ -207,15 +207,15 @@ export class BufReader implements Reader {
* it returns the data read before the error and the error itself
* (often io.EOF).
* ReadString returns err != nil if and only if the returned data does not end
- * in
- * delim.
+ * in delim.
* For simple uses, a Scanner may be more convenient.
*/
async readString(delim: string): Promise<string | Deno.EOF> {
if (delim.length !== 1)
throw new Error("Delimiter should be a single character");
const buffer = await this.readSlice(delim.charCodeAt(0));
- return new TextDecoder().decode(buffer || undefined);
+ if (buffer == Deno.EOF) return Deno.EOF;
+ return new TextDecoder().decode(buffer);
}
/** `readLine()` is a low-level line-reading primitive. Most callers should