Skip to content

Commit

Permalink
fix: Fix TS complains
Browse files Browse the repository at this point in the history
  • Loading branch information
octet-stream committed Jul 3, 2024
1 parent c703078 commit 56ae167
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,6 @@
"editor.codeActionsOnSave": {
"quickfix.biome": "explicit"
}
}
},
"typescript.tsdk": "node_modules/typescript/lib"
}
3 changes: 2 additions & 1 deletion src/blobHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import type {BlobPart} from "./BlobPart.js"

import {isFunction} from "./isFunction.js"
import {isAsyncIterable} from "./isAsyncIterable.js"
import {isReadableStreamFallback} from "./isReadableStreamFallback.js"

export const MAX_CHUNK_SIZE = 65536 // 64 KiB (same size chrome slice theirs blob into Uint8array's)

Expand Down Expand Up @@ -69,7 +70,7 @@ export const getStreamIterator = (
return chunkStream(source)
}

if (isFunction(source.getReader)) {
if (isReadableStreamFallback(source)) {
return chunkStream(readStream(source))
}

Expand Down
9 changes: 9 additions & 0 deletions src/isReadableStreamFallback.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import {isFunction} from "./isFunction.js"

export const isReadableStreamFallback = (
value: unknown
): value is ReadableStream =>
!!value &&
typeof value === "object" &&
!Array.isArray(value) &&
isFunction((value as ReadableStream).getReader)

0 comments on commit 56ae167

Please sign in to comment.