diff --git a/src/platform.web.ts b/src/platform.web.ts index 8db2f501..8758e4c6 100644 --- a/src/platform.web.ts +++ b/src/platform.web.ts @@ -3,8 +3,17 @@ export { d as debug }; // === Export system-specific operations // Turn an AsyncIterable into a stream -export const itrToStream = (itr: AsyncIterable) => - ReadableStream.from(itr); +export const itrToStream = (itr: AsyncIterable) => { + // do not assume ReadableStream.from to exist yet + const it = itr[Symbol.asyncIterator](); + return new ReadableStream({ + async pull(controller) { + const chunk = await it.next(); + if (chunk.done) controller.close(); + else controller.enqueue(chunk.value); + }, + }); +}; // === Base configuration for `fetch` calls export const baseFetchConfig = (_apiRoot: string) => ({});