Apache-2.0
Identifier: Apache-2.0_abort-error_1.0.1
# abort-error
[](https://codecov.io/gh/achingbrain/abort-error)
[](https://github.com/achingbrain/abort-error/actions/workflows/js-test-and-release.yml?query=branch%3Amain)
> An error to be used by AbortSignal handlers
# About
A simple error class and options interface that seems to get copied from
project to project.
## Example - Using `AbortError`
```JavaScript
import { AbortError } from 'abort-error'
// a promise that will be settled later
const deferred = Promise.withResolvers()
const signal = AbortSignal.timeout(1000)
signal.addEventListener('abort', () => {
deferred.reject(new AbortError())
})
```
## Example - Using `AbortOptions`
```TypeScript
import type { AbortOptions } from 'abort-error'
async function myFunction (options?: AbortOptions) {
return fetch('https://example.com', {
signal: options?.signal
})
}
```
# Install
```console
$ npm i abort-error
```
## Browser `
```
# API Docs
-
# License
Licensed under either of
- Apache 2.0, ([LICENSE-APACHE](https://github.com/achingbrain/abort-error/LICENSE-APACHE) / )
- MIT ([LICENSE-MIT](https://github.com/achingbrain/abort-error/LICENSE-MIT) / )
# Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
previous
next