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/README.md b/README.md index 2feb185..ed6b9f9 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. 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"; +}