Skip to content

Commit

Permalink
Merge branch 'main' into sig-not-func
Browse files Browse the repository at this point in the history
  • Loading branch information
KnorpelSenf authored Oct 8, 2023
2 parents 207304b + fb58202 commit e63b5d1
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/platform.web.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,17 @@ export { d as debug };

// === Export system-specific operations
// Turn an AsyncIterable<Uint8Array> into a stream
export const itrToStream = (itr: AsyncIterable<Uint8Array>) =>
ReadableStream.from(itr);
export const itrToStream = (itr: AsyncIterable<Uint8Array>) => {
// 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) => ({});
Expand Down

0 comments on commit e63b5d1

Please sign in to comment.