UNPKG

1.02 kBTypeScriptView Raw
1import { EventTarget } from "event-target-shim"
2
3type Events = {
4 abort: any
5}
6type EventAttributes = {
7 onabort: any
8}
9/**
10 * The signal class.
11 * @see https://dom.spec.whatwg.org/#abortsignal
12 */
13declare class AbortSignal extends EventTarget<Events, EventAttributes> {
14 /**
15 * AbortSignal cannot be constructed directly.
16 */
17 constructor()
18 /**
19 * Returns `true` if this `AbortSignal`"s `AbortController` has signaled to abort, and `false` otherwise.
20 */
21 readonly aborted: boolean
22}
23/**
24 * The AbortController.
25 * @see https://dom.spec.whatwg.org/#abortcontroller
26 */
27declare class AbortController {
28 /**
29 * Initialize this controller.
30 */
31 constructor()
32 /**
33 * Returns the `AbortSignal` object associated with this object.
34 */
35 readonly signal: AbortSignal
36 /**
37 * Abort and signal to any observers that the associated activity is to be aborted.
38 */
39 abort(): void
40}
41
42export default AbortController
43export { AbortController, AbortSignal }