@whatwg-node/node-fetch 0.7.23-alpha-20250725190806-5df0ede70a22656416fd7a0f626f8d5ba8238197 → 0.7.23-alpha-20250725194603-2942304cbf1226c9014b2f3f4c3c94b84b410273
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 +12 -15
- package/esm/utils.js +12 -15
- package/package.json +1 -1
package/cjs/utils.js
CHANGED
@@ -64,22 +64,12 @@ function pipeThrough({ src, dest, signal, onError, }) {
|
|
64
64
|
dest.destroy(e);
|
65
65
|
});
|
66
66
|
if (signal) {
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
}
|
71
|
-
catch (abortError) {
|
72
|
-
// destroying the src stream will destroy the dest stream as well
|
73
|
-
src.destroy(abortError);
|
74
|
-
}
|
67
|
+
// this is faster than `import('node:signal').addAbortSignal(signal, src)`
|
68
|
+
function onAbort() {
|
69
|
+
src.destroy(new AbortError());
|
75
70
|
}
|
76
|
-
|
77
|
-
|
78
|
-
// src stream and not start pipe at all
|
79
|
-
handleAbort();
|
80
|
-
return;
|
81
|
-
}
|
82
|
-
signal.addEventListener('abort', handleAbort, { once: true });
|
71
|
+
signal.addEventListener('abort', onAbort, { once: true });
|
72
|
+
src.once('close', () => signal.removeEventListener('abort', onAbort));
|
83
73
|
}
|
84
74
|
src.pipe(dest, { end: true /* already default */ });
|
85
75
|
}
|
@@ -93,3 +83,10 @@ function safeWrite(chunk, stream) {
|
|
93
83
|
return (0, node_events_1.once)(stream, 'drain');
|
94
84
|
}
|
95
85
|
}
|
86
|
+
// https://github.com/nodejs/node/blob/f692878dec6354c0a82241f224906981861bc840/lib/internal/errors.js#L961-L973
|
87
|
+
class AbortError extends Error {
|
88
|
+
constructor(message = 'The operation was aborted', options = undefined) {
|
89
|
+
super(message, options);
|
90
|
+
this.name = 'AbortError';
|
91
|
+
}
|
92
|
+
}
|
package/esm/utils.js
CHANGED
@@ -51,22 +51,12 @@ export function pipeThrough({ src, dest, signal, onError, }) {
|
|
51
51
|
dest.destroy(e);
|
52
52
|
});
|
53
53
|
if (signal) {
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
}
|
58
|
-
catch (abortError) {
|
59
|
-
// destroying the src stream will destroy the dest stream as well
|
60
|
-
src.destroy(abortError);
|
61
|
-
}
|
54
|
+
// this is faster than `import('node:signal').addAbortSignal(signal, src)`
|
55
|
+
function onAbort() {
|
56
|
+
src.destroy(new AbortError());
|
62
57
|
}
|
63
|
-
|
64
|
-
|
65
|
-
// src stream and not start pipe at all
|
66
|
-
handleAbort();
|
67
|
-
return;
|
68
|
-
}
|
69
|
-
signal.addEventListener('abort', handleAbort, { once: true });
|
58
|
+
signal.addEventListener('abort', onAbort, { once: true });
|
59
|
+
src.once('close', () => signal.removeEventListener('abort', onAbort));
|
70
60
|
}
|
71
61
|
src.pipe(dest, { end: true /* already default */ });
|
72
62
|
}
|
@@ -80,3 +70,10 @@ export function safeWrite(chunk, stream) {
|
|
80
70
|
return once(stream, 'drain');
|
81
71
|
}
|
82
72
|
}
|
73
|
+
// https://github.com/nodejs/node/blob/f692878dec6354c0a82241f224906981861bc840/lib/internal/errors.js#L961-L973
|
74
|
+
class AbortError extends Error {
|
75
|
+
constructor(message = 'The operation was aborted', options = undefined) {
|
76
|
+
super(message, options);
|
77
|
+
this.name = 'AbortError';
|
78
|
+
}
|
79
|
+
}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@whatwg-node/node-fetch",
|
3
|
-
"version": "0.7.23-alpha-
|
3
|
+
"version": "0.7.23-alpha-20250725194603-2942304cbf1226c9014b2f3f4c3c94b84b410273",
|
4
4
|
"description": "Fetch API implementation for Node",
|
5
5
|
"sideEffects": false,
|
6
6
|
"dependencies": {
|