import type { Awaitable } from "./Awaitable"; // from([1, 2, 3]).pipeThrough(filters()); export function flatMaps(fn: (x: T, i: number) => Awaitable) { let i = 0; return new TransformStream({ transform: async (chunk, ctrl) => { (await fn(chunk, i++)).map((e) => ctrl.enqueue(e)); }, }); }