Skip to content

@caido/quickjs-types / llrt/abort

llrt/abort ​

Classes ​

AbortController ​

Constructors ​

Constructor ​

new AbortController(): AbortController

Creates a new AbortController object instance.

Returns ​

AbortController

Properties ​

signal ​

readonly signal: AbortSignal

Returns the AbortSignal object associated with this object.

Methods ​

abort() ​

abort(reason?: any): void

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.

Parameters ​
ParameterType
reason?any
Returns ​

void


AbortSignal ​

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.

Extends ​

Constructors ​

Constructor ​

new AbortSignal(): AbortSignal

Creates a new AbortSignal object instance.

Returns ​

AbortSignal

Overrides ​

EventTarget.constructor

Properties ​

aborted ​

readonly aborted: boolean

Returns true if this AbortSignal's AbortController has signaled to abort, and false otherwise.

onabort ​

onabort: (this: AbortSignal, event: Event) => any | null

Registers an event listener callback to execute when an abort event is observed.

reason ​

readonly reason: any

A JavaScript value providing the abort reason, once the signal has aborted.

Methods ​

addEventListener() ​

addEventListener(type: EventKey, listener: EventListener, options?: AddEventListenerOptions): void

Adds a new handler for the type event. Any given listener is added only once per type.

If the once option is true, the listener is removed after the next time a type event is dispatched.

Parameters ​
ParameterType
typeEventKey
listenerEventListener
options?AddEventListenerOptions
Returns ​

void

Inherited from ​

EventTarget.addEventListener

dispatchEvent() ​

dispatchEvent(event: Event): void

Dispatches a synthetic event event to target

Parameters ​
ParameterType
eventEvent
Returns ​

void

Inherited from ​

EventTarget.dispatchEvent

removeEventListener() ​

removeEventListener(type: EventKey, listener: EventListener): void

Removes the event listener in target's event listener list with the same type and callback

Parameters ​
ParameterType
typeEventKey
listenerEventListener
Returns ​

void

Inherited from ​

EventTarget.removeEventListener

throwIfAborted() ​

throwIfAborted(): void

Throws the signal's abort reason if the signal has been aborted; otherwise it does nothing.

Returns ​

void

abort() ​

static abort(reason?: any): AbortSignal

Returns an AbortSignal instance that is already set as aborted.

Parameters ​
ParameterTypeDescription
reason?anyThe reason for the abort.
Returns ​

AbortSignal

any() ​

static any(signals: AbortSignal[]): AbortSignal

Returns an AbortSignal that aborts when any of the given abort signals abort.

Parameters ​
ParameterTypeDescription
signalsAbortSignal[]An array of AbortSignal objects to observe.
Returns ​

AbortSignal

timeout() ​

static timeout(milliseconds: number): AbortSignal

Returns an AbortSignal instance that will automatically abort after a specified time.

Parameters ​
ParameterTypeDescription
millisecondsnumberThe number of milliseconds to wait before aborting.
Returns ​

AbortSignal