diff --git a/doc/api/globals.md b/doc/api/globals.md index c7e539ca41aade..c81a49ab3ff09d 100644 --- a/doc/api/globals.md +++ b/doc/api/globals.md @@ -44,12 +44,21 @@ ac.abort(); console.log(ac.signal.aborted); // Prints True ``` -### `abortController.abort()` +### `abortController.abort([reason])` +* `reason` {any} An optional reason, retrievable on the `AbortSignal`s + `reason` property. + Triggers the abort signal, causing the `abortController.signal` to emit the `'abort'` event. @@ -72,12 +81,19 @@ added: v15.0.0 The `AbortSignal` is used to notify observers when the `abortController.abort()` method is called. -#### Static method: `AbortSignal.abort()` +#### Static method: `AbortSignal.abort([reason])` +* `reason`: {any} * Returns: {AbortSignal} Returns a new already aborted `AbortSignal`. @@ -136,6 +152,22 @@ added: v15.0.0 An optional callback function that may be set by user code to be notified when the `abortController.abort()` function has been called. +#### `abortSignal.reason` + + + +* Type: {any} + +An optional reason specified when the `AbortSignal` was triggered. + +```js +const ac = new AbortController(); +ac.abort(new Error('boom!')); +console.log(ac.signal.reason); // Error('boom!'); +``` + ## Class: `Buffer`