Skip to main content
Module

x/streamtools/provide.ts>provide

🦕 This is a Deno module that provides utilities for handling Streams API.
Go to Latest
function provide
import { provide } from "https://deno.land/x/streamtools@v0.4.0/provide.ts";

Provides the given values to the writable stream by piping them from a readable stream created from the values. Returns a promise that resolves when all the values have been successfully written to the stream.

import { provide } from "./provide.ts";

const results: number[] = [];
const writer = new WritableStream<number>({
  write(chunk) {
    results.push(chunk);
  },
});

await provide(writer, [1, 2, 3]);
console.log(results); // [1, 2, 3]

Parameters

stream: WritableStream<T>

The writable stream to write the values to.

values: T[]

An array of values to write to the stream.

optional
options: PipeOptions = [UNSUPPORTED]

Options for configuring the piping behavior.

Returns

Promise<void>

A promise that resolves when all values have been successfully written to the stream.