From 9e5e9d44ec8338b8ba8026d5e95803ec3fe7eaf7 Mon Sep 17 00:00:00 2001 From: tsctx <91457664+tsctx@users.noreply.github.com> Date: Wed, 6 Dec 2023 19:36:24 +0900 Subject: [PATCH 1/2] refactor: version cleanup --- lib/core/util.js | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/lib/core/util.js b/lib/core/util.js index 5a28529b663..f7855c7256c 100644 --- a/lib/core/util.js +++ b/lib/core/util.js @@ -334,19 +334,11 @@ function isDisturbed (body) { } function isErrored (body) { - return !!(body && ( - stream.isErrored - ? stream.isErrored(body) - : /state: 'errored'/.test(nodeUtil.inspect(body) - ))) + return !!(body && stream.isErrored(body)) } function isReadable (body) { - return !!(body && ( - stream.isReadable - ? stream.isReadable(body) - : /state: 'readable'/.test(nodeUtil.inspect(body) - ))) + return !!(body && stream.isReadable(body)) } function getSocketInfo (socket) { @@ -417,10 +409,7 @@ function throwIfAborted (signal) { signal.throwIfAborted() } else { if (signal.aborted) { - // DOMException not available < v17.0.0 - const err = new Error('The operation was aborted') - err.name = 'AbortError' - throw err + throw new DOMException('The operation was aborted', 'AbortError') } } } From ed9ca267384910b31127cc202ff627602cc6ce87 Mon Sep 17 00:00:00 2001 From: tsctx <91457664+tsctx@users.noreply.github.com> Date: Thu, 7 Dec 2023 15:28:46 +0900 Subject: [PATCH 2/2] remove throwIfAborted --- lib/core/util.js | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/lib/core/util.js b/lib/core/util.js index f7855c7256c..d221e98673b 100644 --- a/lib/core/util.js +++ b/lib/core/util.js @@ -403,17 +403,6 @@ function isFormDataLike (object) { ) } -function throwIfAborted (signal) { - if (!signal) { return } - if (typeof signal.throwIfAborted === 'function') { - signal.throwIfAborted() - } else { - if (signal.aborted) { - throw new DOMException('The operation was aborted', 'AbortError') - } - } -} - function addAbortListener (signal, listener) { if ('addEventListener' in signal) { signal.addEventListener('abort', listener, { once: true }) @@ -484,7 +473,6 @@ module.exports = { getSocketInfo, isFormDataLike, buildURL, - throwIfAborted, addAbortListener, parseRangeHeader, nodeMajor,