@whatwg-node/node-fetch 0.7.15-alpha-20250323023017-45502ad09a85c652198558a069fe00754e0b502f → 0.7.15-alpha-20250324112015-2e11b9fc0d1303d275a3ae5587de21d9d5daffba
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.
- package/cjs/Body.js +21 -12
- package/cjs/fetchNodeHttp.js +1 -1
- package/esm/Body.js +21 -12
- package/esm/fetchNodeHttp.js +1 -1
- package/package.json +1 -1
- package/typings/Body.d.cts +2 -1
- package/typings/Body.d.ts +2 -1
package/cjs/Body.js
CHANGED
@@ -105,10 +105,7 @@ class PonyfillBody {
|
|
105
105
|
return null;
|
106
106
|
}
|
107
107
|
_chunks = null;
|
108
|
-
|
109
|
-
if (this._chunks) {
|
110
|
-
return (0, utils_js_1.fakePromise)(this._chunks);
|
111
|
-
}
|
108
|
+
_doCollectChunksFromReadableJob() {
|
112
109
|
if (this.bodyType === BodyInitType.AsyncIterable) {
|
113
110
|
if (Array.fromAsync) {
|
114
111
|
return (0, promise_helpers_1.handleMaybePromise)(() => Array.fromAsync(this.bodyInit), chunks => {
|
@@ -117,31 +114,43 @@ class PonyfillBody {
|
|
117
114
|
});
|
118
115
|
}
|
119
116
|
const iterator = this.bodyInit[Symbol.asyncIterator]();
|
117
|
+
const chunks = [];
|
120
118
|
const collectValue = () => (0, promise_helpers_1.handleMaybePromise)(() => iterator.next(), ({ value, done }) => {
|
121
|
-
this._chunks ||= [];
|
122
119
|
if (value) {
|
123
|
-
|
120
|
+
chunks.push(value);
|
124
121
|
}
|
125
122
|
if (!done) {
|
126
123
|
return collectValue();
|
127
124
|
}
|
125
|
+
this._chunks = chunks;
|
128
126
|
return this._chunks;
|
129
127
|
});
|
130
128
|
return collectValue();
|
131
129
|
}
|
132
130
|
const _body = this.generateBody();
|
133
|
-
this._chunks = [];
|
134
131
|
if (!_body) {
|
132
|
+
this._chunks = [];
|
135
133
|
return (0, utils_js_1.fakePromise)(this._chunks);
|
136
134
|
}
|
135
|
+
const chunks = [];
|
137
136
|
_body.readable.on('data', chunk => {
|
138
|
-
|
137
|
+
chunks.push(chunk);
|
139
138
|
});
|
140
139
|
return new Promise((resolve, reject) => {
|
141
|
-
_body.readable.once('end', () =>
|
140
|
+
_body.readable.once('end', () => {
|
141
|
+
this._chunks = chunks;
|
142
|
+
resolve(this._chunks);
|
143
|
+
});
|
142
144
|
_body.readable.once('error', reject);
|
143
145
|
});
|
144
146
|
}
|
147
|
+
_collectChunksFromReadable() {
|
148
|
+
if (this._chunks) {
|
149
|
+
return (0, utils_js_1.fakePromise)(this._chunks);
|
150
|
+
}
|
151
|
+
this._chunks ||= this._doCollectChunksFromReadableJob();
|
152
|
+
return this._chunks;
|
153
|
+
}
|
145
154
|
_blob = null;
|
146
155
|
blob() {
|
147
156
|
if (this._blob) {
|
@@ -397,10 +406,10 @@ function processBodyInit(bodyInit, signal) {
|
|
397
406
|
};
|
398
407
|
}
|
399
408
|
if (bodyInit instanceof node_http_1.IncomingMessage) {
|
400
|
-
const passthrough = (bodyInit = bodyInit.pipe(new node_stream_1.PassThrough(
|
401
|
-
end: true,
|
402
|
-
// @ts-expect-error - `signal` is not in the type definition
|
409
|
+
const passthrough = (bodyInit = bodyInit.pipe(new node_stream_1.PassThrough({
|
403
410
|
signal,
|
411
|
+
}), {
|
412
|
+
end: true,
|
404
413
|
}));
|
405
414
|
return {
|
406
415
|
bodyType: BodyInitType.Readable,
|
package/cjs/fetchNodeHttp.js
CHANGED
@@ -101,7 +101,7 @@ function fetchNodeHttp(fetchRequest) {
|
|
101
101
|
if (statusText == null) {
|
102
102
|
statusText = '';
|
103
103
|
}
|
104
|
-
const ponyfillResponse = new Response_js_1.PonyfillResponse(outputStream, {
|
104
|
+
const ponyfillResponse = new Response_js_1.PonyfillResponse(outputStream || nodeResponse, {
|
105
105
|
status: statusCode,
|
106
106
|
statusText,
|
107
107
|
headers: nodeResponse.headers,
|
package/esm/Body.js
CHANGED
@@ -101,10 +101,7 @@ export class PonyfillBody {
|
|
101
101
|
return null;
|
102
102
|
}
|
103
103
|
_chunks = null;
|
104
|
-
|
105
|
-
if (this._chunks) {
|
106
|
-
return fakePromise(this._chunks);
|
107
|
-
}
|
104
|
+
_doCollectChunksFromReadableJob() {
|
108
105
|
if (this.bodyType === BodyInitType.AsyncIterable) {
|
109
106
|
if (Array.fromAsync) {
|
110
107
|
return handleMaybePromise(() => Array.fromAsync(this.bodyInit), chunks => {
|
@@ -113,31 +110,43 @@ export class PonyfillBody {
|
|
113
110
|
});
|
114
111
|
}
|
115
112
|
const iterator = this.bodyInit[Symbol.asyncIterator]();
|
113
|
+
const chunks = [];
|
116
114
|
const collectValue = () => handleMaybePromise(() => iterator.next(), ({ value, done }) => {
|
117
|
-
this._chunks ||= [];
|
118
115
|
if (value) {
|
119
|
-
|
116
|
+
chunks.push(value);
|
120
117
|
}
|
121
118
|
if (!done) {
|
122
119
|
return collectValue();
|
123
120
|
}
|
121
|
+
this._chunks = chunks;
|
124
122
|
return this._chunks;
|
125
123
|
});
|
126
124
|
return collectValue();
|
127
125
|
}
|
128
126
|
const _body = this.generateBody();
|
129
|
-
this._chunks = [];
|
130
127
|
if (!_body) {
|
128
|
+
this._chunks = [];
|
131
129
|
return fakePromise(this._chunks);
|
132
130
|
}
|
131
|
+
const chunks = [];
|
133
132
|
_body.readable.on('data', chunk => {
|
134
|
-
|
133
|
+
chunks.push(chunk);
|
135
134
|
});
|
136
135
|
return new Promise((resolve, reject) => {
|
137
|
-
_body.readable.once('end', () =>
|
136
|
+
_body.readable.once('end', () => {
|
137
|
+
this._chunks = chunks;
|
138
|
+
resolve(this._chunks);
|
139
|
+
});
|
138
140
|
_body.readable.once('error', reject);
|
139
141
|
});
|
140
142
|
}
|
143
|
+
_collectChunksFromReadable() {
|
144
|
+
if (this._chunks) {
|
145
|
+
return fakePromise(this._chunks);
|
146
|
+
}
|
147
|
+
this._chunks ||= this._doCollectChunksFromReadableJob();
|
148
|
+
return this._chunks;
|
149
|
+
}
|
141
150
|
_blob = null;
|
142
151
|
blob() {
|
143
152
|
if (this._blob) {
|
@@ -392,10 +401,10 @@ function processBodyInit(bodyInit, signal) {
|
|
392
401
|
};
|
393
402
|
}
|
394
403
|
if (bodyInit instanceof IncomingMessage) {
|
395
|
-
const passthrough = (bodyInit = bodyInit.pipe(new PassThrough(
|
396
|
-
end: true,
|
397
|
-
// @ts-expect-error - `signal` is not in the type definition
|
404
|
+
const passthrough = (bodyInit = bodyInit.pipe(new PassThrough({
|
398
405
|
signal,
|
406
|
+
}), {
|
407
|
+
end: true,
|
399
408
|
}));
|
400
409
|
return {
|
401
410
|
bodyType: BodyInitType.Readable,
|
package/esm/fetchNodeHttp.js
CHANGED
@@ -98,7 +98,7 @@ export function fetchNodeHttp(fetchRequest) {
|
|
98
98
|
if (statusText == null) {
|
99
99
|
statusText = '';
|
100
100
|
}
|
101
|
-
const ponyfillResponse = new PonyfillResponse(outputStream, {
|
101
|
+
const ponyfillResponse = new PonyfillResponse(outputStream || nodeResponse, {
|
102
102
|
status: statusCode,
|
103
103
|
statusText,
|
104
104
|
headers: nodeResponse.headers,
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@whatwg-node/node-fetch",
|
3
|
-
"version": "0.7.15-alpha-
|
3
|
+
"version": "0.7.15-alpha-20250324112015-2e11b9fc0d1303d275a3ae5587de21d9d5daffba",
|
4
4
|
"description": "Fetch API implementation for Node",
|
5
5
|
"sideEffects": false,
|
6
6
|
"dependencies": {
|
package/typings/Body.d.cts
CHANGED
@@ -34,7 +34,8 @@ export declare class PonyfillBody<TJSON = any> implements Body {
|
|
34
34
|
headers: Headers;
|
35
35
|
}, forceSet?: boolean): void;
|
36
36
|
get body(): PonyfillReadableStream<Uint8Array> | null;
|
37
|
-
_chunks: Uint8Array[] | null;
|
37
|
+
_chunks: MaybePromise<Uint8Array[]> | null;
|
38
|
+
_doCollectChunksFromReadableJob(): MaybePromise<Uint8Array<ArrayBufferLike>[]>;
|
38
39
|
_collectChunksFromReadable(): MaybePromise<Uint8Array<ArrayBufferLike>[]>;
|
39
40
|
_blob: PonyfillBlob | null;
|
40
41
|
blob(): Promise<PonyfillBlob>;
|
package/typings/Body.d.ts
CHANGED
@@ -34,7 +34,8 @@ export declare class PonyfillBody<TJSON = any> implements Body {
|
|
34
34
|
headers: Headers;
|
35
35
|
}, forceSet?: boolean): void;
|
36
36
|
get body(): PonyfillReadableStream<Uint8Array> | null;
|
37
|
-
_chunks: Uint8Array[] | null;
|
37
|
+
_chunks: MaybePromise<Uint8Array[]> | null;
|
38
|
+
_doCollectChunksFromReadableJob(): MaybePromise<Uint8Array<ArrayBufferLike>[]>;
|
38
39
|
_collectChunksFromReadable(): MaybePromise<Uint8Array<ArrayBufferLike>[]>;
|
39
40
|
_blob: PonyfillBlob | null;
|
40
41
|
blob(): Promise<PonyfillBlob>;
|