Skip to main content
Module

x/streamtools/pipe_through_from.ts>pipeThroughFrom

🦕 This is a Deno module that provides utilities for handling Streams API.
Latest
function pipeThroughFrom
import { pipeThroughFrom } from "https://deno.land/x/streamtools@v1.0.0/pipe_through_from.ts";

Pipes the readable side of a TransformStream to a WritableStream. Returns the writable side of the TransformStream for further piping.

import { channel } from "./channel.ts";
import { collect } from "./collect.ts";
import { pipeThroughFrom } from "./pipe_through_from.ts";

const encoder = new TextEncoder();
const output = channel<string>();
const stream = pipeThroughFrom(output.writer, new TextDecoderStream());
const writer = stream.getWriter();

await writer.write(encoder.encode("Hello"));
await writer.write(encoder.encode("World"));
await writer.close();
writer.releaseLock();

const result = await collect(output.reader);
console.log(result); // ["Hello", "World"]

Type Parameters

I

The type of data that the readable side of the TransformStream accepts.

O

The type of data that the TransformStream transforms the input data into.

Parameters

stream: WritableStream<O>

The destination WritableStream to pipe the data into.

transform: TransformStream<I, O>

The TransformStream that transforms the input data.

Returns

The writable side of the TransformStream for further piping.