@whatwg-node/node-fetch 0.0.1-alpha-20221005124556-f602970 → 0.0.1-alpha-20221005124650-55319ef
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/AbortController.d.ts +1 -1
- package/Body.d.ts +3 -3
- package/File.d.ts +1 -1
- package/ReadableStream.d.ts +2 -2
- package/Request.d.ts +2 -2
- package/Response.d.ts +2 -2
- package/fetch.d.ts +2 -2
- package/index.js +14 -11
- package/index.mjs +14 -11
- package/package.json +1 -1
package/AbortController.d.ts
CHANGED
package/Body.d.ts
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
/// <reference types="node" />
|
2
2
|
import { PonyfillBlob } from './Blob';
|
3
|
-
import { Readable } from
|
4
|
-
import { PonyfillFormData } from
|
5
|
-
import { PonyfillReadableStream } from
|
3
|
+
import { Readable } from 'stream';
|
4
|
+
import { PonyfillFormData } from './FormData';
|
5
|
+
import { PonyfillReadableStream } from './ReadableStream';
|
6
6
|
export declare type BodyPonyfillInit = XMLHttpRequestBodyInit | Readable | PonyfillReadableStream<Uint8Array>;
|
7
7
|
export declare class BodyPonyfill implements Body {
|
8
8
|
private bodyInit;
|
package/File.d.ts
CHANGED
package/ReadableStream.d.ts
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
/// <reference types="node" />
|
2
|
-
import { Readable } from
|
2
|
+
import { Readable } from 'stream';
|
3
3
|
export declare class PonyfillReadableStream<T> implements ReadableStream<T> {
|
4
4
|
readable: Readable;
|
5
5
|
constructor(underlyingSource?: UnderlyingSource<T> | Readable | ReadableStream<T> | PonyfillReadableStream<T>);
|
@@ -9,7 +9,7 @@ export declare class PonyfillReadableStream<T> implements ReadableStream<T> {
|
|
9
9
|
[Symbol.asyncIterator](): AsyncIterableIterator<any>;
|
10
10
|
tee(): [ReadableStream<T>, ReadableStream<T>];
|
11
11
|
pipeTo(destination: WritableStream<T>): Promise<void>;
|
12
|
-
pipeThrough<T2>({ writable, readable }: {
|
12
|
+
pipeThrough<T2>({ writable, readable, }: {
|
13
13
|
writable: WritableStream<T>;
|
14
14
|
readable: ReadableStream<T2>;
|
15
15
|
}): ReadableStream<T2>;
|
package/Request.d.ts
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
import { BodyPonyfill, BodyPonyfillInit } from
|
2
|
-
import { PonyfillHeadersInit } from
|
1
|
+
import { BodyPonyfill, BodyPonyfillInit } from './Body';
|
2
|
+
import { PonyfillHeadersInit } from './Headers';
|
3
3
|
export declare type RequestPonyfillInit = Omit<RequestInit, 'body' | 'headers'> & {
|
4
4
|
body?: BodyPonyfillInit | null;
|
5
5
|
headers?: PonyfillHeadersInit;
|
package/Response.d.ts
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
import { BodyPonyfill, BodyPonyfillInit } from
|
2
|
-
import { PonyfillHeadersInit } from
|
1
|
+
import { BodyPonyfill, BodyPonyfillInit } from './Body';
|
2
|
+
import { PonyfillHeadersInit } from './Headers';
|
3
3
|
export declare type ResponsePonyfilInit = Omit<ResponseInit, 'headers'> & {
|
4
4
|
url?: string;
|
5
5
|
redirected?: boolean;
|
package/fetch.d.ts
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
import { PonyfillRequest, RequestPonyfillInit } from
|
2
|
-
import { PonyfillResponse } from
|
1
|
+
import { PonyfillRequest, RequestPonyfillInit } from './Request';
|
2
|
+
import { PonyfillResponse } from './Response';
|
3
3
|
export declare const fetchPonyfill: (info: string | PonyfillRequest | URL, init?: RequestPonyfillInit) => Promise<PonyfillResponse>;
|
package/index.js
CHANGED
@@ -113,7 +113,7 @@ function createController(desiredSize, readable) {
|
|
113
113
|
},
|
114
114
|
error(error) {
|
115
115
|
readable.destroy(error);
|
116
|
-
}
|
116
|
+
},
|
117
117
|
};
|
118
118
|
}
|
119
119
|
class PonyfillReadableStream {
|
@@ -130,20 +130,23 @@ class PonyfillReadableStream {
|
|
130
130
|
const reader = underlyingSource.getReader();
|
131
131
|
this.readable = new stream.Readable({
|
132
132
|
read() {
|
133
|
-
reader
|
133
|
+
reader
|
134
|
+
.read()
|
135
|
+
.then(({ value, done }) => {
|
134
136
|
if (done) {
|
135
137
|
this.push(null);
|
136
138
|
}
|
137
139
|
else {
|
138
140
|
this.push(value);
|
139
141
|
}
|
140
|
-
})
|
142
|
+
})
|
143
|
+
.catch(err => {
|
141
144
|
this.destroy(err);
|
142
145
|
});
|
143
146
|
},
|
144
147
|
destroy(err, callback) {
|
145
148
|
reader.cancel(err).then(() => callback(err), callback);
|
146
|
-
}
|
149
|
+
},
|
147
150
|
});
|
148
151
|
}
|
149
152
|
else {
|
@@ -165,7 +168,7 @@ class PonyfillReadableStream {
|
|
165
168
|
catch (err) {
|
166
169
|
callback(err);
|
167
170
|
}
|
168
|
-
}
|
171
|
+
},
|
169
172
|
});
|
170
173
|
}
|
171
174
|
}
|
@@ -210,7 +213,7 @@ class PonyfillReadableStream {
|
|
210
213
|
await writer.ready;
|
211
214
|
return writer.close();
|
212
215
|
}
|
213
|
-
pipeThrough({ writable, readable }) {
|
216
|
+
pipeThrough({ writable, readable, }) {
|
214
217
|
this.pipeTo(writable);
|
215
218
|
return readable;
|
216
219
|
}
|
@@ -290,7 +293,7 @@ class BodyPonyfill {
|
|
290
293
|
controller.enqueue(Buffer.from(`Content-Disposition: form-data; name="${key}"\r\n\r\n`));
|
291
294
|
controller.enqueue(Buffer.from(value));
|
292
295
|
}
|
293
|
-
if (Number(i) ===
|
296
|
+
if (Number(i) === entries.length - 1) {
|
294
297
|
controller.enqueue(Buffer.from(`\r\n--${boundary}--\r\n`));
|
295
298
|
}
|
296
299
|
else {
|
@@ -298,7 +301,7 @@ class BodyPonyfill {
|
|
298
301
|
}
|
299
302
|
}
|
300
303
|
controller.close();
|
301
|
-
}
|
304
|
+
},
|
302
305
|
});
|
303
306
|
}
|
304
307
|
else if ('buffer' in this.bodyInit) {
|
@@ -528,7 +531,7 @@ class PonyfillResponse extends BodyPonyfill {
|
|
528
531
|
static error() {
|
529
532
|
const response = new PonyfillResponse(null, {
|
530
533
|
status: 500,
|
531
|
-
statusText: 'Internal Server Error'
|
534
|
+
statusText: 'Internal Server Error',
|
532
535
|
});
|
533
536
|
return response;
|
534
537
|
}
|
@@ -538,9 +541,9 @@ class PonyfillResponse extends BodyPonyfill {
|
|
538
541
|
}
|
539
542
|
return new PonyfillResponse(null, {
|
540
543
|
headers: {
|
541
|
-
location: url
|
544
|
+
location: url,
|
542
545
|
},
|
543
|
-
status
|
546
|
+
status,
|
544
547
|
});
|
545
548
|
}
|
546
549
|
}
|
package/index.mjs
CHANGED
@@ -109,7 +109,7 @@ function createController(desiredSize, readable) {
|
|
109
109
|
},
|
110
110
|
error(error) {
|
111
111
|
readable.destroy(error);
|
112
|
-
}
|
112
|
+
},
|
113
113
|
};
|
114
114
|
}
|
115
115
|
class PonyfillReadableStream {
|
@@ -126,20 +126,23 @@ class PonyfillReadableStream {
|
|
126
126
|
const reader = underlyingSource.getReader();
|
127
127
|
this.readable = new Readable({
|
128
128
|
read() {
|
129
|
-
reader
|
129
|
+
reader
|
130
|
+
.read()
|
131
|
+
.then(({ value, done }) => {
|
130
132
|
if (done) {
|
131
133
|
this.push(null);
|
132
134
|
}
|
133
135
|
else {
|
134
136
|
this.push(value);
|
135
137
|
}
|
136
|
-
})
|
138
|
+
})
|
139
|
+
.catch(err => {
|
137
140
|
this.destroy(err);
|
138
141
|
});
|
139
142
|
},
|
140
143
|
destroy(err, callback) {
|
141
144
|
reader.cancel(err).then(() => callback(err), callback);
|
142
|
-
}
|
145
|
+
},
|
143
146
|
});
|
144
147
|
}
|
145
148
|
else {
|
@@ -161,7 +164,7 @@ class PonyfillReadableStream {
|
|
161
164
|
catch (err) {
|
162
165
|
callback(err);
|
163
166
|
}
|
164
|
-
}
|
167
|
+
},
|
165
168
|
});
|
166
169
|
}
|
167
170
|
}
|
@@ -206,7 +209,7 @@ class PonyfillReadableStream {
|
|
206
209
|
await writer.ready;
|
207
210
|
return writer.close();
|
208
211
|
}
|
209
|
-
pipeThrough({ writable, readable }) {
|
212
|
+
pipeThrough({ writable, readable, }) {
|
210
213
|
this.pipeTo(writable);
|
211
214
|
return readable;
|
212
215
|
}
|
@@ -286,7 +289,7 @@ class BodyPonyfill {
|
|
286
289
|
controller.enqueue(Buffer.from(`Content-Disposition: form-data; name="${key}"\r\n\r\n`));
|
287
290
|
controller.enqueue(Buffer.from(value));
|
288
291
|
}
|
289
|
-
if (Number(i) ===
|
292
|
+
if (Number(i) === entries.length - 1) {
|
290
293
|
controller.enqueue(Buffer.from(`\r\n--${boundary}--\r\n`));
|
291
294
|
}
|
292
295
|
else {
|
@@ -294,7 +297,7 @@ class BodyPonyfill {
|
|
294
297
|
}
|
295
298
|
}
|
296
299
|
controller.close();
|
297
|
-
}
|
300
|
+
},
|
298
301
|
});
|
299
302
|
}
|
300
303
|
else if ('buffer' in this.bodyInit) {
|
@@ -524,7 +527,7 @@ class PonyfillResponse extends BodyPonyfill {
|
|
524
527
|
static error() {
|
525
528
|
const response = new PonyfillResponse(null, {
|
526
529
|
status: 500,
|
527
|
-
statusText: 'Internal Server Error'
|
530
|
+
statusText: 'Internal Server Error',
|
528
531
|
});
|
529
532
|
return response;
|
530
533
|
}
|
@@ -534,9 +537,9 @@ class PonyfillResponse extends BodyPonyfill {
|
|
534
537
|
}
|
535
538
|
return new PonyfillResponse(null, {
|
536
539
|
headers: {
|
537
|
-
location: url
|
540
|
+
location: url,
|
538
541
|
},
|
539
|
-
status
|
542
|
+
status,
|
540
543
|
});
|
541
544
|
}
|
542
545
|
}
|
package/package.json
CHANGED