Skip to content

Commit

Permalink
doc: update output of example in AbortController
Browse files Browse the repository at this point in the history
Actual output of example in AbortController is mismatched.
Plus, make `reason` parameter as optional in JSDoc.

Refs: https://github.com/nodejs/node/blob/main/doc/api/globals.md#abortcontrollerabortreason
Refs: https://github.com/nodejs/node/blob/main/doc/api/globals.md#static-method-abortsignalabortreason
PR-URL: #47227
Reviewed-By: Debadree Chatterjee <[email protected]>
Reviewed-By: Erick Wendel <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
  • Loading branch information
deokjinkim authored and danielleadams committed Jul 6, 2023
1 parent 1f08f48 commit d15f522
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions doc/api/globals.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ ac.signal.addEventListener('abort', () => console.log('Aborted!'),

ac.abort();

console.log(ac.signal.aborted); // Prints True
console.log(ac.signal.aborted); // Prints true
```

### `abortController.abort([reason])`
Expand Down Expand Up @@ -196,7 +196,7 @@ 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!');
console.log(ac.signal.reason); // Error: boom!
```

#### `abortSignal.throwIfAborted()`
Expand Down
4 changes: 2 additions & 2 deletions lib/internal/abort_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ class AbortSignal extends EventTarget {
}

/**
* @param {any} reason
* @param {any} [reason]
* @returns {AbortSignal}
*/
static abort(
Expand Down Expand Up @@ -337,7 +337,7 @@ class AbortController {
}

/**
* @param {any} reason
* @param {any} [reason]
*/
abort(reason = new DOMException('This operation was aborted', 'AbortError')) {
validateAbortController(this);
Expand Down

0 comments on commit d15f522

Please sign in to comment.