11
22// TODO (jimmywarting): in the feature use conditional loading with top level await (requires 14.x)
3- // Node has recently added whatwg stream into core, want to use that instead when it becomes available.
3+ // Node has recently added whatwg stream into core
44
55import './streams.cjs' ;
66
@@ -21,8 +21,8 @@ async function * toIterator (parts, clone = true) {
2121 while ( position !== end ) {
2222 const size = Math . min ( end - position , POOL_SIZE ) ;
2323 const chunk = part . buffer . slice ( position , position + size ) ;
24- yield new Uint8Array ( chunk ) ;
2524 position += chunk . byteLength ;
25+ yield new Uint8Array ( chunk ) ;
2626 }
2727 } else {
2828 yield part ;
@@ -42,7 +42,7 @@ async function * toIterator (parts, clone = true) {
4242 }
4343}
4444
45- export default class Blob {
45+ const _Blob = class Blob {
4646
4747 /** @type {Array.<(Blob|Uint8Array)> } */
4848 #parts = [ ] ;
@@ -69,7 +69,7 @@ export default class Blob {
6969 } else if ( element instanceof Blob ) {
7070 part = element ;
7171 } else {
72- part = new TextEncoder ( ) . encode ( String ( element ) ) ;
72+ part = new TextEncoder ( ) . encode ( element ) ;
7373 }
7474
7575 size += ArrayBuffer . isView ( part ) ? part . byteLength : part . size ;
@@ -224,10 +224,12 @@ export default class Blob {
224224 }
225225}
226226
227- Object . defineProperties ( Blob . prototype , {
227+ Object . defineProperties ( _Blob . prototype , {
228228 size : { enumerable : true } ,
229229 type : { enumerable : true } ,
230230 slice : { enumerable : true }
231231} ) ;
232232
233- export { Blob } ;
233+ /** @type {typeof globalThis.Blob } */
234+ export const Blob = _Blob ;
235+ export default Blob ;
0 commit comments