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 @@ -64,6 +64,7 @@ const {
64
64
65
65
const kHandle = Symbol ( 'kHandle' ) ;
66
66
const kState = Symbol ( 'kState' ) ;
67
+ const kIndex = Symbol ( 'kIndex' ) ;
67
68
const kType = Symbol ( 'kType' ) ;
68
69
const kLength = Symbol ( 'kLength' ) ;
69
70
const kArrayBufferPromise = Symbol ( 'kArrayBufferPromise' ) ;
@@ -323,17 +324,17 @@ class Blob {
323
324
return new lazyReadableStream ( {
324
325
async start ( ) {
325
326
this [ kState ] = await self . arrayBuffer ( ) ;
327
+ this [ kIndex ] = 0 ;
326
328
} ,
327
329
328
330
pull ( controller ) {
329
- if ( this [ kState ] . byteLength <= kMaxChunkSize ) {
330
- controller . enqueue ( new Uint8Array ( this [ kState ] ) ) ;
331
+ if ( this [ kState ] . byteLength - this [ kIndex ] <= kMaxChunkSize ) {
332
+ controller . enqueue ( new Uint8Array ( this [ kState ] , this [ kIndex ] ) ) ;
331
333
controller . close ( ) ;
332
334
this [ kState ] = undefined ;
333
335
} else {
334
- const slice = this [ kState ] . slice ( 0 , kMaxChunkSize ) ;
335
- this [ kState ] = this [ kState ] . slice ( kMaxChunkSize ) ;
336
- controller . enqueue ( new Uint8Array ( slice ) ) ;
336
+ controller . enqueue ( new Uint8Array ( this [ kState ] , this [ kIndex ] , kMaxChunkSize ) ) ;
337
+ this [ kIndex ] += kMaxChunkSize ;
337
338
}
338
339
}
339
340
} ) ;
You can’t perform that action at this time.
0 commit comments