std/streams
2021-12-13 14:18:17 +01:00
..
conversion_test.ts feat: streams utilities (#1141) 2021-10-12 11:51:48 +02:00
conversion.ts [BREAKING] Remove 'server_legacy' from 'http' module (#1648) 2021-12-13 14:18:17 +01:00
delimiter_test.ts feat: streams utilities (#1141) 2021-10-12 11:51:48 +02:00
delimiter.ts feat: streams utilities (#1141) 2021-10-12 11:51:48 +02:00
merge_test.ts feat: streams utilities (#1141) 2021-10-12 11:51:48 +02:00
merge.ts feat: streams utilities (#1141) 2021-10-12 11:51:48 +02:00
mod.ts feat: streams utilities (#1141) 2021-10-12 11:51:48 +02:00
README.md feat: streams utilities (#1141) 2021-10-12 11:51:48 +02:00

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();