function stream
thefrontside/effectionConvert any AsyncIterable into an Effection Stream.
This allows you to consume any AsyncIterable as a Stream.
Examples
Example 1
import { each, stream, until } from "effection";
let response = yield* until(fetch("https://example.com/data.bin"));
if (!response.body) throw new Error("response has no body");
for (let chunk of yield* each(stream(response.body))) {
console.log(chunk.byteLength);
yield* each.next();
}
Type Parameters
T
R
Parameters
iterable: AsyncIterable<T, R>
the async iterable to convert
Return Type
Stream<T, R>
a stream that will produce each item of iterable