summaryrefslogtreecommitdiff
path: root/std/io/bufio.ts
diff options
context:
space:
mode:
Diffstat (limited to 'std/io/bufio.ts')
-rw-r--r--std/io/bufio.ts10
1 files changed, 9 insertions, 1 deletions
diff --git a/std/io/bufio.ts b/std/io/bufio.ts
index 954fc5eee..df3ecb002 100644
--- a/std/io/bufio.ts
+++ b/std/io/bufio.ts
@@ -706,5 +706,13 @@ export async function* readStringDelim(
export async function* readLines(
reader: Reader,
): AsyncIterableIterator<string> {
- yield* readStringDelim(reader, "\n");
+ for await (let chunk of readStringDelim(reader, "\n")) {
+ // Finding a CR at the end of the line is evidence of a
+ // "\r\n" at the end of the line. The "\r" part should be
+ // removed too.
+ if (chunk.endsWith("\r")) {
+ chunk = chunk.slice(0, -1);
+ }
+ yield chunk;
+ }
}