abort static method

AbortSignal abort([
  1. JSAny? reason
])

The AbortSignal.abort() static method returns an AbortSignal that is already set as aborted (and which does not trigger an AbortSignal.abort_event event).

This is shorthand for the following code:

const controller = new AbortController();
controller.abort();
return controller.signal;

This could, for example, be passed to a fetch method in order to run its abort logic (i.e. it may be that code is organized such that the abort logic should be run even if the intended fetch operation has not been started).

Note: The method is similar in purpose to Promise.reject.

Implementation

external static AbortSignal abort([JSAny? reason]);