diff --git a/doc/api/globals.md b/doc/api/globals.md index 8cc52e3a01433f..88e9aad9df21f8 100644 --- a/doc/api/globals.md +++ b/doc/api/globals.md @@ -46,14 +46,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. @@ -80,14 +87,19 @@ added: 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`. @@ -152,6 +164,22 @@ added: 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`