Skip to main content

@std/streams@0.215.0

latest
Works with
It is unknown whether this package works with Browsers, Deno, Node.js, Cloudflare Workers, Bun
It is unknown whether this package works with Browsers
It is unknown whether this package works with Deno
It is unknown whether this package works with Node.js
It is unknown whether this package works with Cloudflare Workers
It is unknown whether this package works with Bun
JSR Score70%
Published2 years ago (0.215.0)
function toTransformStream
toTransformStream<I, O>(
transformer: (src: ReadableStream<I>) => Iterable<O> | AsyncIterable<O>,
writableStrategy?: QueuingStrategy<I>,
readableStrategy?: QueuingStrategy<O>
): TransformStream<I, O>

Convert the generator function into a TransformStream.

Examples

Example 1

import { toTransformStream } from "@std/streams/to_transform_stream";

const readable = ReadableStream.from([0, 1, 2])
  .pipeThrough(toTransformStream(async function* (src) {
    for await (const chunk of src) {
      yield chunk * 100;
    }
  }));

for await (const chunk of readable) {
  console.log(chunk);
}
// output: 0, 100, 200

Type Parameters

Parameters

transformer: (src: ReadableStream<I>) => Iterable<O> | AsyncIterable<O>

A function to transform.

optional
writableStrategy: QueuingStrategy<I>

An object that optionally defines a queuing strategy for the stream.

optional
readableStrategy: QueuingStrategy<O>

An object that optionally defines a queuing strategy for the stream.

Return Type

Report package

Please provide a reason for reporting this package. We will review your report and take appropriate action.

Please review the JSR usage policy before submitting a report.

Add Package

deno add jsr:@std/streams

Import symbol

import { toTransformStream } from "@std/streams";
or

Import directly with a jsr specifier

import { toTransformStream } from "jsr:@std/streams";