@whatwg-node/node-fetch 0.5.11-alpha-20240327142842-26e172534a26bc875f63385a16971fbdc5b95d8b → 0.5.11-rc-20240426123347-cab1f2d198b4b41c6a8951d576f361aac1c34e6d
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/ReadableStream.js +0 -3
- package/cjs/Response.js +0 -3
- package/cjs/fetchNodeHttp.js +1 -0
- package/cjs/index.js +0 -3
- package/cjs/utils.js +1 -19
- package/esm/ReadableStream.js +0 -3
- package/esm/Response.js +0 -3
- package/esm/fetchNodeHttp.js +1 -0
- package/esm/index.js +0 -3
- package/esm/utils.js +0 -17
- package/package.json +1 -1
- package/typings/ReadableStream.d.cts +0 -1
- package/typings/ReadableStream.d.ts +0 -1
- package/typings/Response.d.cts +0 -1
- package/typings/Response.d.ts +0 -1
- package/typings/utils.d.cts +0 -1
- package/typings/utils.d.ts +0 -1
package/cjs/ReadableStream.js
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
"use strict";
|
2
|
-
var _a;
|
3
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
4
3
|
exports.PonyfillReadableStream = void 0;
|
5
4
|
const stream_1 = require("stream");
|
@@ -53,7 +52,6 @@ function isReadableStream(obj) {
|
|
53
52
|
class PonyfillReadableStream {
|
54
53
|
constructor(underlyingSource) {
|
55
54
|
this.locked = false;
|
56
|
-
this[_a] = 'ReadableStream';
|
57
55
|
if (underlyingSource instanceof PonyfillReadableStream && underlyingSource.readable != null) {
|
58
56
|
this.readable = underlyingSource.readable;
|
59
57
|
}
|
@@ -174,4 +172,3 @@ class PonyfillReadableStream {
|
|
174
172
|
}
|
175
173
|
}
|
176
174
|
exports.PonyfillReadableStream = PonyfillReadableStream;
|
177
|
-
_a = Symbol.toStringTag;
|
package/cjs/Response.js
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
"use strict";
|
2
|
-
var _a;
|
3
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
4
3
|
exports.PonyfillResponse = void 0;
|
5
4
|
const http_1 = require("http");
|
@@ -9,7 +8,6 @@ const JSON_CONTENT_TYPE = 'application/json; charset=utf-8';
|
|
9
8
|
class PonyfillResponse extends Body_js_1.PonyfillBody {
|
10
9
|
constructor(body, init) {
|
11
10
|
super(body || null, init);
|
12
|
-
this[_a] = 'Response';
|
13
11
|
this.headers =
|
14
12
|
init?.headers && (0, Headers_js_1.isHeadersLike)(init.headers)
|
15
13
|
? init.headers
|
@@ -73,4 +71,3 @@ class PonyfillResponse extends Body_js_1.PonyfillBody {
|
|
73
71
|
}
|
74
72
|
}
|
75
73
|
exports.PonyfillResponse = PonyfillResponse;
|
76
|
-
_a = Symbol.toStringTag;
|
package/cjs/fetchNodeHttp.js
CHANGED
package/cjs/index.js
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.URLSearchParams = exports.URL = exports.btoa = exports.TextDecoder = exports.TextEncoder = exports.Blob = exports.FormData = exports.File = exports.ReadableStream = exports.Response = exports.Request = exports.Body = exports.Headers = exports.fetch = void 0;
|
4
|
-
const utils_js_1 = require("./utils.js");
|
5
4
|
var fetch_js_1 = require("./fetch.js");
|
6
5
|
Object.defineProperty(exports, "fetch", { enumerable: true, get: function () { return fetch_js_1.fetchPonyfill; } });
|
7
6
|
var Headers_js_1 = require("./Headers.js");
|
@@ -28,5 +27,3 @@ var URL_js_1 = require("./URL.js");
|
|
28
27
|
Object.defineProperty(exports, "URL", { enumerable: true, get: function () { return URL_js_1.PonyfillURL; } });
|
29
28
|
var URLSearchParams_js_1 = require("./URLSearchParams.js");
|
30
29
|
Object.defineProperty(exports, "URLSearchParams", { enumerable: true, get: function () { return URLSearchParams_js_1.PonyfillURLSearchParams; } });
|
31
|
-
// Not sure it is the right thing to do, but it is the only way to make it work for Fastify
|
32
|
-
(0, utils_js_1.patchReadableFromWeb)();
|
package/cjs/utils.js
CHANGED
@@ -1,27 +1,9 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.isNodeReadable = exports.isArrayBufferView = exports.fakePromise = exports.defaultHeadersSerializer = exports.getHeadersObj =
|
4
|
-
const stream_1 = require("stream");
|
3
|
+
exports.isNodeReadable = exports.isArrayBufferView = exports.fakePromise = exports.defaultHeadersSerializer = exports.getHeadersObj = void 0;
|
5
4
|
function isHeadersInstance(obj) {
|
6
5
|
return obj?.forEach != null;
|
7
6
|
}
|
8
|
-
function patchReadableFromWeb() {
|
9
|
-
try {
|
10
|
-
const originalReadableFromWeb = stream_1.Readable.fromWeb;
|
11
|
-
if (originalReadableFromWeb.name !== 'ReadableFromWebPatchedByWhatWgNode') {
|
12
|
-
stream_1.Readable.fromWeb = function ReadableFromWebPatchedByWhatWgNode(stream) {
|
13
|
-
if (stream.readable != null) {
|
14
|
-
return stream.readable;
|
15
|
-
}
|
16
|
-
return originalReadableFromWeb(stream);
|
17
|
-
};
|
18
|
-
}
|
19
|
-
}
|
20
|
-
catch (e) {
|
21
|
-
console.warn('Could not patch Readable.fromWeb, so this might break Readable.fromWeb usage with the whatwg-node and the integrations like Fastify', e);
|
22
|
-
}
|
23
|
-
}
|
24
|
-
exports.patchReadableFromWeb = patchReadableFromWeb;
|
25
7
|
function getHeadersObj(headers) {
|
26
8
|
if (headers == null || !isHeadersInstance(headers)) {
|
27
9
|
return headers;
|
package/esm/ReadableStream.js
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
var _a;
|
2
1
|
import { Readable } from 'stream';
|
3
2
|
function createController(desiredSize, readable) {
|
4
3
|
let chunks = [];
|
@@ -50,7 +49,6 @@ function isReadableStream(obj) {
|
|
50
49
|
export class PonyfillReadableStream {
|
51
50
|
constructor(underlyingSource) {
|
52
51
|
this.locked = false;
|
53
|
-
this[_a] = 'ReadableStream';
|
54
52
|
if (underlyingSource instanceof PonyfillReadableStream && underlyingSource.readable != null) {
|
55
53
|
this.readable = underlyingSource.readable;
|
56
54
|
}
|
@@ -170,4 +168,3 @@ export class PonyfillReadableStream {
|
|
170
168
|
return isReadableStream(instance);
|
171
169
|
}
|
172
170
|
}
|
173
|
-
_a = Symbol.toStringTag;
|
package/esm/Response.js
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
var _a;
|
2
1
|
import { STATUS_CODES } from 'http';
|
3
2
|
import { PonyfillBody } from './Body.js';
|
4
3
|
import { isHeadersLike, PonyfillHeaders } from './Headers.js';
|
@@ -6,7 +5,6 @@ const JSON_CONTENT_TYPE = 'application/json; charset=utf-8';
|
|
6
5
|
export class PonyfillResponse extends PonyfillBody {
|
7
6
|
constructor(body, init) {
|
8
7
|
super(body || null, init);
|
9
|
-
this[_a] = 'Response';
|
10
8
|
this.headers =
|
11
9
|
init?.headers && isHeadersLike(init.headers)
|
12
10
|
? init.headers
|
@@ -69,4 +67,3 @@ export class PonyfillResponse extends PonyfillBody {
|
|
69
67
|
return new PonyfillResponse(JSON.stringify(data), init);
|
70
68
|
}
|
71
69
|
}
|
72
|
-
_a = Symbol.toStringTag;
|
package/esm/fetchNodeHttp.js
CHANGED
package/esm/index.js
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
import { patchReadableFromWeb } from './utils.js';
|
2
1
|
export { fetchPonyfill as fetch } from './fetch.js';
|
3
2
|
export { PonyfillHeaders as Headers } from './Headers.js';
|
4
3
|
export { PonyfillBody as Body } from './Body.js';
|
@@ -11,5 +10,3 @@ export { PonyfillBlob as Blob } from './Blob.js';
|
|
11
10
|
export { PonyfillTextEncoder as TextEncoder, PonyfillTextDecoder as TextDecoder, PonyfillBtoa as btoa, } from './TextEncoderDecoder.js';
|
12
11
|
export { PonyfillURL as URL } from './URL.js';
|
13
12
|
export { PonyfillURLSearchParams as URLSearchParams } from './URLSearchParams.js';
|
14
|
-
// Not sure it is the right thing to do, but it is the only way to make it work for Fastify
|
15
|
-
patchReadableFromWeb();
|
package/esm/utils.js
CHANGED
@@ -1,23 +1,6 @@
|
|
1
|
-
import { Readable } from 'stream';
|
2
1
|
function isHeadersInstance(obj) {
|
3
2
|
return obj?.forEach != null;
|
4
3
|
}
|
5
|
-
export function patchReadableFromWeb() {
|
6
|
-
try {
|
7
|
-
const originalReadableFromWeb = Readable.fromWeb;
|
8
|
-
if (originalReadableFromWeb.name !== 'ReadableFromWebPatchedByWhatWgNode') {
|
9
|
-
Readable.fromWeb = function ReadableFromWebPatchedByWhatWgNode(stream) {
|
10
|
-
if (stream.readable != null) {
|
11
|
-
return stream.readable;
|
12
|
-
}
|
13
|
-
return originalReadableFromWeb(stream);
|
14
|
-
};
|
15
|
-
}
|
16
|
-
}
|
17
|
-
catch (e) {
|
18
|
-
console.warn('Could not patch Readable.fromWeb, so this might break Readable.fromWeb usage with the whatwg-node and the integrations like Fastify', e);
|
19
|
-
}
|
20
|
-
}
|
21
4
|
export function getHeadersObj(headers) {
|
22
5
|
if (headers == null || !isHeadersInstance(headers)) {
|
23
6
|
return headers;
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@whatwg-node/node-fetch",
|
3
|
-
"version": "0.5.11-
|
3
|
+
"version": "0.5.11-rc-20240426123347-cab1f2d198b4b41c6a8951d576f361aac1c34e6d",
|
4
4
|
"description": "Fetch API implementation for Node",
|
5
5
|
"sideEffects": false,
|
6
6
|
"dependencies": {
|
@@ -17,5 +17,4 @@ export declare class PonyfillReadableStream<T> implements ReadableStream<T> {
|
|
17
17
|
readable: ReadableStream<T2>;
|
18
18
|
}): ReadableStream<T2>;
|
19
19
|
static [Symbol.hasInstance](instance: unknown): instance is PonyfillReadableStream<unknown>;
|
20
|
-
[Symbol.toStringTag]: string;
|
21
20
|
}
|
@@ -17,5 +17,4 @@ export declare class PonyfillReadableStream<T> implements ReadableStream<T> {
|
|
17
17
|
readable: ReadableStream<T2>;
|
18
18
|
}): ReadableStream<T2>;
|
19
19
|
static [Symbol.hasInstance](instance: unknown): instance is PonyfillReadableStream<unknown>;
|
20
|
-
[Symbol.toStringTag]: string;
|
21
20
|
}
|
package/typings/Response.d.cts
CHANGED
@@ -19,5 +19,4 @@ export declare class PonyfillResponse<TJSON = any> extends PonyfillBody<TJSON> i
|
|
19
19
|
static error(): PonyfillResponse<any>;
|
20
20
|
static redirect(url: string, status?: number): PonyfillResponse<any>;
|
21
21
|
static json<T = any>(data: T, init?: ResponsePonyfilInit): PonyfillResponse<T>;
|
22
|
-
[Symbol.toStringTag]: string;
|
23
22
|
}
|
package/typings/Response.d.ts
CHANGED
@@ -19,5 +19,4 @@ export declare class PonyfillResponse<TJSON = any> extends PonyfillBody<TJSON> i
|
|
19
19
|
static error(): PonyfillResponse<any>;
|
20
20
|
static redirect(url: string, status?: number): PonyfillResponse<any>;
|
21
21
|
static json<T = any>(data: T, init?: ResponsePonyfilInit): PonyfillResponse<T>;
|
22
|
-
[Symbol.toStringTag]: string;
|
23
22
|
}
|
package/typings/utils.d.cts
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
/// <reference types="node" />
|
2
2
|
import { Readable } from 'stream';
|
3
|
-
export declare function patchReadableFromWeb(): void;
|
4
3
|
export declare function getHeadersObj(headers: Headers): Record<string, string>;
|
5
4
|
export declare function defaultHeadersSerializer(headers: Headers, onContentLength?: (value: string) => void): string[];
|
6
5
|
export declare function fakePromise<T>(value: T): Promise<T>;
|
package/typings/utils.d.ts
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
/// <reference types="node" />
|
2
2
|
import { Readable } from 'stream';
|
3
|
-
export declare function patchReadableFromWeb(): void;
|
4
3
|
export declare function getHeadersObj(headers: Headers): Record<string, string>;
|
5
4
|
export declare function defaultHeadersSerializer(headers: Headers, onContentLength?: (value: string) => void): string[];
|
6
5
|
export declare function fakePromise<T>(value: T): Promise<T>;
|