From 3ed3d10a1bfdadebc0d5145d0f9ca7dbb180d088 Mon Sep 17 00:00:00 2001 From: Jannik Zschiesche Date: Thu, 4 Apr 2024 09:43:45 +0200 Subject: [PATCH 1/2] Add `isAbortError()` --- CHANGELOG.md | 6 ++++++ src/network.ts | 15 +++++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 src/network.ts diff --git a/CHANGELOG.md b/CHANGELOG.md index b5658c0..13a79f1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +2.1.2 (unreleased) +===== + +* (improvement) Add `isAbortError()`. + + 2.1.1 ===== diff --git a/src/network.ts b/src/network.ts new file mode 100644 index 0000000..6b23ed5 --- /dev/null +++ b/src/network.ts @@ -0,0 +1,15 @@ +/** + * Returns whether the given error is an abort "error". + * + * This will be thrown in a fetch() when aborting the request. + * + * @example + * const controller = new AbortController(); + * fetch(..., {signal: controller.signal}) + * .catch(error => isAbortError(error) // will be true) + * controller.abort(); + */ +export function isAbortError (error: unknown) : boolean +{ + return error instanceof DOMException && error.name === "AbortError"; +} From f7d579594283c6f115c66b29f815b866a0e6773c Mon Sep 17 00:00:00 2001 From: Jannik Zschiesche Date: Thu, 4 Apr 2024 09:43:50 +0200 Subject: [PATCH 2/2] Clarify README --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 73392bf..3435139 100644 --- a/README.md +++ b/README.md @@ -12,9 +12,9 @@ Development ### Releases 1. Check the CHANGELOG, to ensure that the next version number is correct according to semver and there is no "(unreleased)" after the next version number. -2. Commit these changes, commit message "Release x.y.z" -3. Push these changes -4. Tag the latest commit with "x.y.z" -5. Push the tag. +2. If necessary, commit these changes, commit message "Release x.y.z". +3. Tag the latest commit with "x.y.z". +4. Push commit + tag. +5. Create a release in GitHub. Publishing to npm is done automatically in a GitHub action.