mirror of
https://github.com/denoland/std.git
synced 2024-11-22 04:59:05 +00:00
.. | ||
buffer_test.ts | ||
buffer.ts | ||
conversion_test.ts | ||
conversion.ts | ||
delimiter_test.ts | ||
delimiter.ts | ||
merge_test.ts | ||
merge.ts | ||
mod.ts | ||
README.md |
std/streams
Conversion
readerFromStreamReader
Creates a Reader
from a ReadableStreamDefaultReader
.
import {
copy,
readerFromStreamReader,
} from "https://deno.land/std@$STD_VERSION/streams/mod.ts";
const res = await fetch("https://deno.land");
const file = await Deno.open("./deno.land.html", { create: true, write: true });
const reader = readerFromStreamReader(res.body!.getReader());
await copy(reader, file);
file.close();
writerFromStreamWriter
Creates a Writer
from a WritableStreamDefaultWriter
.
import {
copy,
writerFromStreamWriter,
} from "https://deno.land/std@$STD_VERSION/streams/mod.ts";
const file = await Deno.open("./deno.land.html", { read: true });
const writableStream = new WritableStream({
write(chunk): void {
console.log(chunk);
},
});
const writer = writerFromStreamWriter(writableStream.getWriter());
await copy(file, writer);
file.close();