mirror of
https://github.com/denoland/std.git
synced 2024-11-21 20:50:22 +00:00
work
This commit is contained in:
parent
fdcec21070
commit
4e50956b4d
@ -12,7 +12,7 @@ export interface TextLineStreamOptions {
|
||||
|
||||
/**
|
||||
* Transform a stream into a stream where each chunk is divided by a newline,
|
||||
* be it `\n` or `\r\n`.
|
||||
* be it `\n` or `\r\n`. `\r` can be enabled via the `allowCR` option.
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
|
@ -24,6 +24,15 @@ Deno.test("TextLineStream() parses simple input", async () => {
|
||||
"",
|
||||
"654321\r",
|
||||
]);
|
||||
|
||||
const stream2 = ReadableStream.from("rewq0987\r\n\r\n654321\n")
|
||||
.pipeThrough(new TextLineStream());
|
||||
|
||||
assertEquals(await Array.fromAsync(stream2), [
|
||||
"rewq0987",
|
||||
"",
|
||||
"654321",
|
||||
]);
|
||||
});
|
||||
|
||||
Deno.test("TextLineStream() parses with `allowCR` enabled", async () => {
|
||||
@ -35,7 +44,6 @@ Deno.test("TextLineStream() parses with `allowCR` enabled", async () => {
|
||||
"\nrewq0987\n\n654321",
|
||||
"\nrewq0987\r\n\r\n654321\r",
|
||||
]).pipeThrough(new TextLineStream({ allowCR: true }));
|
||||
|
||||
assertEquals(await Array.fromAsync(stream), [
|
||||
"qwertzuiopasd",
|
||||
"mnbvcxylk",
|
||||
@ -51,6 +59,15 @@ Deno.test("TextLineStream() parses with `allowCR` enabled", async () => {
|
||||
"",
|
||||
"654321",
|
||||
]);
|
||||
|
||||
const stream2 = ReadableStream.from("rewq0987\r\n\r\n654321\n")
|
||||
.pipeThrough(new TextLineStream());
|
||||
|
||||
assertEquals(await Array.fromAsync(stream2), [
|
||||
"rewq0987",
|
||||
"",
|
||||
"654321",
|
||||
]);
|
||||
});
|
||||
|
||||
Deno.test("TextLineStream() parses large chunks", async () => {
|
||||
|
Loading…
Reference in New Issue
Block a user