diff options
Diffstat (limited to 'op_crates/web/lib.deno_web.d.ts')
-rw-r--r-- | op_crates/web/lib.deno_web.d.ts | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/op_crates/web/lib.deno_web.d.ts b/op_crates/web/lib.deno_web.d.ts index b402529e2..d24a3b76f 100644 --- a/op_crates/web/lib.deno_web.d.ts +++ b/op_crates/web/lib.deno_web.d.ts @@ -1,5 +1,7 @@ // Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. +/* eslint-disable @typescript-eslint/no-explicit-any */ + /// <reference no-default-lib="true" /> /// <reference lib="esnext" /> @@ -185,3 +187,51 @@ declare class TextEncoder { ): { read: number; written: number }; readonly [Symbol.toStringTag]: string; } + +/** A controller object that allows you to abort one or more DOM requests as and + * when desired. */ +declare class AbortController { + /** Returns the AbortSignal object associated with this object. */ + readonly signal: AbortSignal; + /** Invoking this method will set this object's AbortSignal's aborted flag and + * signal to any observers that the associated activity is to be aborted. */ + abort(): void; +} + +interface AbortSignalEventMap { + abort: Event; +} + +/** A signal object that allows you to communicate with a DOM request (such as a + * Fetch) and abort it if required via an AbortController object. */ +interface AbortSignal extends EventTarget { + /** Returns true if this AbortSignal's AbortController has signaled to abort, + * and false otherwise. */ + readonly aborted: boolean; + onabort: ((this: AbortSignal, ev: Event) => any) | null; + addEventListener<K extends keyof AbortSignalEventMap>( + type: K, + listener: (this: AbortSignal, ev: AbortSignalEventMap[K]) => any, + options?: boolean | AddEventListenerOptions, + ): void; + addEventListener( + type: string, + listener: EventListenerOrEventListenerObject, + options?: boolean | AddEventListenerOptions, + ): void; + removeEventListener<K extends keyof AbortSignalEventMap>( + type: K, + listener: (this: AbortSignal, ev: AbortSignalEventMap[K]) => any, + options?: boolean | EventListenerOptions, + ): void; + removeEventListener( + type: string, + listener: EventListenerOrEventListenerObject, + options?: boolean | EventListenerOptions, + ): void; +} + +declare const AbortSignal: { + prototype: AbortSignal; + new (): AbortSignal; +}; |