Skip to content
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
fixup! add doc
  • Loading branch information
debadree25 committed Feb 4, 2023
commit 0a58ffc057cdbecc7965092e95d829d54110ebe1
29 changes: 29 additions & 0 deletions doc/api/util.md
Original file line number Diff line number Diff line change
Expand Up @@ -1989,6 +1989,35 @@ const channel = new MessageChannel();
channel.port2.postMessage(signal, [signal]);
```

## `util.aborted(signal, resource)`

<!-- YAML
added: REPLACEME
-->

> Stability: 1 - Experimental

* `signal` {AbortSignal}
* `resource` {any} Any non-null entity
Comment thread
jasnell marked this conversation as resolved.
Outdated
* Returns: {Promise}

Listens to abort event on the provided `signal` and returns a promise which is
resolved if an abort event is triggered. The function cleans up any
event listeners depending on when the provided `resource` is garbage collected.

```js
Comment thread
debadree25 marked this conversation as resolved.
Outdated
const { aborted } = require('util');
Comment thread
debadree25 marked this conversation as resolved.
Outdated

const ac = new AbortController();
const dependent = {};
Comment thread
aduh95 marked this conversation as resolved.
Outdated

aborted(ac.signal, dependent).then(() => {
// Do something when the abort event is triggered.
});

doSomething(dependent, ac.signal); // Can trigger the abort event
```

## `util.types`

<!-- YAML
Expand Down