@whatwg-node/node-fetch 0.5.18-alpha-20240726144438-d85e825aca3e8ac57c7758d5ec88ed5c27358fcc → 0.5.18-alpha-20240726152542-5f316782934ecd79aef9ea23affd78bb05e47164
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/utils.js +22 -11
- package/esm/utils.js +22 -11
- package/package.json +1 -1
package/cjs/utils.js
CHANGED
@@ -13,19 +13,30 @@ function isHeadersInstance(obj) {
|
|
13
13
|
function patchReadableFromWeb() {
|
14
14
|
try {
|
15
15
|
const originalReadableFromWeb = stream_1.Readable.fromWeb;
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
16
|
+
// eslint-disable-next-line no-inner-declarations
|
17
|
+
function ReadableFromWebPatchedByWhatWgNode(stream) {
|
18
|
+
if (stream.readable instanceof stream_1.Readable) {
|
19
|
+
return stream.readable;
|
20
|
+
}
|
21
|
+
return originalReadableFromWeb(stream);
|
22
|
+
}
|
23
|
+
if (typeof jest === 'object' &&
|
24
|
+
typeof afterEach === 'function' &&
|
25
|
+
originalReadableFromWeb.name !== 'ReadableFromWebPatchedByWhatWgNode') {
|
26
|
+
// To relax jest, we should remove the patch after each test
|
27
|
+
beforeEach(() => {
|
28
|
+
if (stream_1.Readable.fromWeb.name !== 'ReadableFromWebPatchedByWhatWgNode') {
|
29
|
+
stream_1.Readable.fromWeb = ReadableFromWebPatchedByWhatWgNode;
|
20
30
|
}
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
// To relax jest, we should remove the patch after each test
|
25
|
-
afterEach(() => {
|
31
|
+
});
|
32
|
+
afterEach(() => {
|
33
|
+
if (stream_1.Readable.fromWeb.name === 'ReadableFromWebPatchedByWhatWgNode') {
|
26
34
|
stream_1.Readable.fromWeb = originalReadableFromWeb;
|
27
|
-
}
|
28
|
-
}
|
35
|
+
}
|
36
|
+
});
|
37
|
+
}
|
38
|
+
else if (originalReadableFromWeb.name !== 'ReadableFromWebPatchedByWhatWgNode') {
|
39
|
+
stream_1.Readable.fromWeb = ReadableFromWebPatchedByWhatWgNode;
|
29
40
|
}
|
30
41
|
}
|
31
42
|
catch (e) {
|
package/esm/utils.js
CHANGED
@@ -5,19 +5,30 @@ function isHeadersInstance(obj) {
|
|
5
5
|
export function patchReadableFromWeb() {
|
6
6
|
try {
|
7
7
|
const originalReadableFromWeb = Readable.fromWeb;
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
8
|
+
// eslint-disable-next-line no-inner-declarations
|
9
|
+
function ReadableFromWebPatchedByWhatWgNode(stream) {
|
10
|
+
if (stream.readable instanceof Readable) {
|
11
|
+
return stream.readable;
|
12
|
+
}
|
13
|
+
return originalReadableFromWeb(stream);
|
14
|
+
}
|
15
|
+
if (typeof jest === 'object' &&
|
16
|
+
typeof afterEach === 'function' &&
|
17
|
+
originalReadableFromWeb.name !== 'ReadableFromWebPatchedByWhatWgNode') {
|
18
|
+
// To relax jest, we should remove the patch after each test
|
19
|
+
beforeEach(() => {
|
20
|
+
if (Readable.fromWeb.name !== 'ReadableFromWebPatchedByWhatWgNode') {
|
21
|
+
Readable.fromWeb = ReadableFromWebPatchedByWhatWgNode;
|
12
22
|
}
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
// To relax jest, we should remove the patch after each test
|
17
|
-
afterEach(() => {
|
23
|
+
});
|
24
|
+
afterEach(() => {
|
25
|
+
if (Readable.fromWeb.name === 'ReadableFromWebPatchedByWhatWgNode') {
|
18
26
|
Readable.fromWeb = originalReadableFromWeb;
|
19
|
-
}
|
20
|
-
}
|
27
|
+
}
|
28
|
+
});
|
29
|
+
}
|
30
|
+
else if (originalReadableFromWeb.name !== 'ReadableFromWebPatchedByWhatWgNode') {
|
31
|
+
Readable.fromWeb = ReadableFromWebPatchedByWhatWgNode;
|
21
32
|
}
|
22
33
|
}
|
23
34
|
catch (e) {
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@whatwg-node/node-fetch",
|
3
|
-
"version": "0.5.18-alpha-
|
3
|
+
"version": "0.5.18-alpha-20240726152542-5f316782934ecd79aef9ea23affd78bb05e47164",
|
4
4
|
"description": "Fetch API implementation for Node",
|
5
5
|
"sideEffects": false,
|
6
6
|
"dependencies": {
|