Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
doc: update output of example in AbortController
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
  • Loading branch information
deokjinkim committed Mar 23, 2023
commit ad99e25b771585fccd2dcdb61e456ed83a832809
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 @@ -326,7 +326,7 @@ class AbortController {
}

/**
* @param {any} reason
* @param {any} [reason]
*/
abort(reason = new DOMException('This operation was aborted', 'AbortError')) {
abortSignal(this.#signal ??= createAbortSignal(), reason);
Expand Down