diff options
author | Dmitry Sharshakov <d3dx12.xx@gmail.com> | 2019-09-22 20:04:46 +0300 |
---|---|---|
committer | Ryan Dahl <ry@tinyclouds.org> | 2019-09-22 13:04:46 -0400 |
commit | 9739ba55df5afef922f96b107f91dbb37128bf5a (patch) | |
tree | 69ad53e718ee8b5846f9d1c1c79740b31c464325 /io/bufio.ts | |
parent | f545f1d571a154c53f6bda3a30bd69a298d63846 (diff) |
Implement readString (denoland/deno_std#607)
Original: https://github.com/denoland/deno_std/commit/20b6408e105f5dd1dbcd0a252d1956b3de1024ca
Diffstat (limited to 'io/bufio.ts')
-rw-r--r-- | io/bufio.ts | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/io/bufio.ts b/io/bufio.ts index 9a7bf1dc1..c158e5051 100644 --- a/io/bufio.ts +++ b/io/bufio.ts @@ -211,8 +211,11 @@ export class BufReader implements Reader { * delim. * For simple uses, a Scanner may be more convenient. */ - async readString(_delim: string): Promise<string | Deno.EOF> { - throw new Error("Not implemented"); + 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); } /** `readLine()` is a low-level line-reading primitive. Most callers should |