File tree 1 file changed +6
-5
lines changed
1 file changed +6
-5
lines changed Original file line number Diff line number Diff line change @@ -65,6 +65,7 @@ const {
65
65
66
66
const kHandle = Symbol ( 'kHandle' ) ;
67
67
const kState = Symbol ( 'kState' ) ;
68
+ const kIndex = Symbol ( 'kIndex' ) ;
68
69
const kType = Symbol ( 'kType' ) ;
69
70
const kLength = Symbol ( 'kLength' ) ;
70
71
const kArrayBufferPromise = Symbol ( 'kArrayBufferPromise' ) ;
@@ -325,17 +326,17 @@ class Blob {
325
326
return new lazyReadableStream ( {
326
327
async start ( ) {
327
328
this [ kState ] = await self . arrayBuffer ( ) ;
329
+ this [ kIndex ] = 0 ;
328
330
} ,
329
331
330
332
pull ( controller ) {
331
- if ( this [ kState ] . byteLength <= kMaxChunkSize ) {
332
- controller . enqueue ( new Uint8Array ( this [ kState ] ) ) ;
333
+ if ( this [ kState ] . byteLength - this [ kIndex ] <= kMaxChunkSize ) {
334
+ controller . enqueue ( new Uint8Array ( this [ kState ] , this [ kIndex ] ) ) ;
333
335
controller . close ( ) ;
334
336
this [ kState ] = undefined ;
335
337
} else {
336
- const slice = this [ kState ] . slice ( 0 , kMaxChunkSize ) ;
337
- this [ kState ] = this [ kState ] . slice ( kMaxChunkSize ) ;
338
- controller . enqueue ( new Uint8Array ( slice ) ) ;
338
+ controller . enqueue ( new Uint8Array ( this [ kState ] , this [ kIndex ] , kMaxChunkSize ) ) ;
339
+ this [ kIndex ] += kMaxChunkSize ;
339
340
}
340
341
}
341
342
} ) ;
You can’t perform that action at this time.
0 commit comments