@whatwg-node/node-fetch 0.4.6 → 0.4.7-rc-20230710183802-40c2cb4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/cjs/Body.js +16 -8
  2. package/esm/Body.js +16 -8
  3. package/package.json +1 -1
package/cjs/Body.js CHANGED
@@ -89,15 +89,23 @@ class PonyfillBody {
89
89
  const blob = await this.blob();
90
90
  return blob.arrayBuffer();
91
91
  }
92
- async _collectChunksFromReadable() {
93
- const chunks = [];
94
- const _body = this.generateBody();
95
- if (_body) {
96
- for await (const chunk of _body.readable) {
97
- chunks.push(chunk);
92
+ _collectChunksFromReadable() {
93
+ return new Promise((resolve, reject) => {
94
+ const chunks = [];
95
+ const _body = this.generateBody();
96
+ if (_body) {
97
+ _body.readable.on('data', chunk => {
98
+ chunks.push(chunk);
99
+ });
100
+ _body.readable.on('end', () => {
101
+ resolve(chunks);
102
+ });
103
+ _body.readable.on('error', e => {
104
+ reject(e);
105
+ });
98
106
  }
99
- }
100
- return chunks;
107
+ return chunks;
108
+ });
101
109
  }
102
110
  async blob() {
103
111
  if (this.bodyType === BodyInitType.Blob) {
package/esm/Body.js CHANGED
@@ -85,15 +85,23 @@ export class PonyfillBody {
85
85
  const blob = await this.blob();
86
86
  return blob.arrayBuffer();
87
87
  }
88
- async _collectChunksFromReadable() {
89
- const chunks = [];
90
- const _body = this.generateBody();
91
- if (_body) {
92
- for await (const chunk of _body.readable) {
93
- chunks.push(chunk);
88
+ _collectChunksFromReadable() {
89
+ return new Promise((resolve, reject) => {
90
+ const chunks = [];
91
+ const _body = this.generateBody();
92
+ if (_body) {
93
+ _body.readable.on('data', chunk => {
94
+ chunks.push(chunk);
95
+ });
96
+ _body.readable.on('end', () => {
97
+ resolve(chunks);
98
+ });
99
+ _body.readable.on('error', e => {
100
+ reject(e);
101
+ });
94
102
  }
95
- }
96
- return chunks;
103
+ return chunks;
104
+ });
97
105
  }
98
106
  async blob() {
99
107
  if (this.bodyType === BodyInitType.Blob) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@whatwg-node/node-fetch",
3
- "version": "0.4.6",
3
+ "version": "0.4.7-rc-20230710183802-40c2cb4",
4
4
  "description": "Fetch API implementation for Node",
5
5
  "sideEffects": false,
6
6
  "dependencies": {