File tree Expand file tree Collapse file tree 2 files changed +14
-3
lines changed Expand file tree Collapse file tree 2 files changed +14
-3
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ ' @whatwg-node/node-fetch ' : patch
3
+ ---
4
+
5
+ Avoid ` .toArray ` and use ` Readable ` 's native listeners directly
Original file line number Diff line number Diff line change @@ -179,9 +179,15 @@ export class PonyfillBody<TJSON = any> implements Body {
179
179
this . _chunks = [ ] ;
180
180
return fakePromise ( this . _chunks ) ;
181
181
}
182
- return _body . readable . toArray ( ) . then ( chunks => {
183
- this . _chunks = chunks ;
184
- return this . _chunks ;
182
+ const chunks : Uint8Array [ ] = [ ] ;
183
+ return new Promise < Uint8Array [ ] > ( ( resolve , reject ) => {
184
+ _body . readable . on ( 'data' , chunk => {
185
+ chunks . push ( chunk ) ;
186
+ } ) ;
187
+ _body . readable . once ( 'error' , reject ) ;
188
+ _body . readable . once ( 'end' , ( ) => {
189
+ resolve ( ( this . _chunks = chunks ) ) ;
190
+ } ) ;
185
191
} ) ;
186
192
}
187
193
You can’t perform that action at this time.
0 commit comments