Skip to content

Commit

Permalink
Merge pull request #33 from 21TORR/abort-error
Browse files Browse the repository at this point in the history
Add `isAbortError`
  • Loading branch information
apfelbox authored Apr 22, 2024
2 parents 40f34d8 + f7d5795 commit 8f1c5d3
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 4 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
2.1.2 (unreleased)
=====

* (improvement) Add `isAbortError()`.


2.1.1
=====

Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
15 changes: 15 additions & 0 deletions src/network.ts
Original file line number Diff line number Diff line change
@@ -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";
}

0 comments on commit 8f1c5d3

Please sign in to comment.