Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/dtils/deps.ts>streamUtils.writerFromStreamWriter

The best unofficial library of utilities for Deno applications
Go to Latest
function streamUtils.writerFromStreamWriter
import { streamUtils } from "https://deno.land/x/dtils@2.2.0/deps.ts";
const { writerFromStreamWriter } = streamUtils;

Create a Writer from a WritableStreamDefaultWriter.

Examples

Example 1

import { copy } from "https://deno.land/std@0.224.0/streams/copy.ts";
import { writerFromStreamWriter } from "https://deno.land/std@0.224.0/streams/writer_from_stream_writer.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();

Parameters

streamWriter: WritableStreamDefaultWriter<Uint8Array>

Returns

Writer