Go to Latest
function readableStreamFromIterable
import { readableStreamFromIterable } from "https://deno.land/std@0.105.0/io/mod.ts";

Create a ReadableStream from any kind of iterable.

 const r1 = readableStreamFromIterable(["foo, bar, baz"]);
 const r2 = readableStreamFromIterable((async function* () {
   await new Promise(((r) => setTimeout(r, 1000)));
   yield "foo";
   await new Promise(((r) => setTimeout(r, 1000)));
   yield "bar";
   await new Promise(((r) => setTimeout(r, 1000)));
   yield "baz";
 })());

Parameters

iterable: Iterable<T> | AsyncIterable<T>