1
1
2
2
// 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
4
4
5
5
import './streams.cjs' ;
6
6
@@ -21,8 +21,8 @@ async function * toIterator (parts, clone = true) {
21
21
while ( position !== end ) {
22
22
const size = Math . min ( end - position , POOL_SIZE ) ;
23
23
const chunk = part . buffer . slice ( position , position + size ) ;
24
- yield new Uint8Array ( chunk ) ;
25
24
position += chunk . byteLength ;
25
+ yield new Uint8Array ( chunk ) ;
26
26
}
27
27
} else {
28
28
yield part ;
@@ -42,7 +42,7 @@ async function * toIterator (parts, clone = true) {
42
42
}
43
43
}
44
44
45
- export default class Blob {
45
+ const _Blob = class Blob {
46
46
47
47
/** @type {Array.<(Blob|Uint8Array)> } */
48
48
#parts = [ ] ;
@@ -69,7 +69,7 @@ export default class Blob {
69
69
} else if ( element instanceof Blob ) {
70
70
part = element ;
71
71
} else {
72
- part = new TextEncoder ( ) . encode ( String ( element ) ) ;
72
+ part = new TextEncoder ( ) . encode ( element ) ;
73
73
}
74
74
75
75
size += ArrayBuffer . isView ( part ) ? part . byteLength : part . size ;
@@ -224,10 +224,12 @@ export default class Blob {
224
224
}
225
225
}
226
226
227
- Object . defineProperties ( Blob . prototype , {
227
+ Object . defineProperties ( _Blob . prototype , {
228
228
size : { enumerable : true } ,
229
229
type : { enumerable : true } ,
230
230
slice : { enumerable : true }
231
231
} ) ;
232
232
233
- export { Blob } ;
233
+ /** @type {typeof globalThis.Blob } */
234
+ export const Blob = _Blob ;
235
+ export default Blob ;
0 commit comments