abort-error

A simple error class and options interface that seems to get copied from project to project.

Example: Using `AbortError`

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`

import type { AbortOptions } from 'abort-error'

async function myFunction (options?: AbortOptions) {
return fetch('https://example.com', {
signal: options?.signal
})
}

Index

Classes

Interfaces