Skip to content

Commit

Permalink
feat: expose createBlobReaderStream
Browse files Browse the repository at this point in the history
  • Loading branch information
zenmumbler committed Jul 22, 2022
1 parent f181721 commit c9db3d0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
10 changes: 10 additions & 0 deletions packages/streams-fetch-adapter/dist/sd-streams-fetch-adapter.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,16 @@ export declare function createAdaptedResponse(
customReadableStreamTee: ReadableStreamTeeFunction
): ResponseConstructor;

/**
* Create a reader for a Blob using FileReader. Given that FileReader has to use the Blob's
* stream() to read it, only use this for Blob implementations without a stream function to
* avoid likely endless recursion or other weirndess.
* @param blob The blob to read the data from
* @param streamCtor A constructor for the ReadableStream to create
* @returns A readable stream for the blob
*/
export function createBlobReaderStream(blob: Blob, streamCtor: ReadableStreamConstructor): ReadableStream;

/**
* Wrap the Blob constructor to add or patch handling of Blob's stream function.
* @param nativeBlob The constructor function of the browser's built in Blob class
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ export function createAdaptedResponse(
* @param streamCtor A constructor for the ReadableStream to create
* @returns A readable stream for the blob
*/
function createBlobReaderStream(blob: Blob, streamCtor: ReadableStreamConstructor) {
export function createBlobReaderStream(blob: Blob, streamCtor: ReadableStreamConstructor) {
const reader = new FileReader();
let reading = false;

Expand Down

0 comments on commit c9db3d0

Please sign in to comment.