diff options
author | flakey5 <73616808+flakey5@users.noreply.github.com> | 2022-07-29 21:31:24 +0300 |
---|---|---|
committer | James M Snell <jasnell@gmail.com> | 2022-08-04 18:40:50 +0300 |
commit | 64ad66bc9975133424cac19fb751fc7a79017303 (patch) | |
tree | 77a7e9ef6b74912a13c0b22a8c44dc73a851d336 /doc/api/util.md | |
parent | be5face1571136e8f9af3fe6c5f0006ea6ed1ea9 (diff) |
lib: refactor transferable AbortSignal
Co-authored-by: James M Snell <jasnell@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/44048
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Stephen Belanger <admin@stephenbelanger.com>
Reviewed-By: Paolo Insogna <paolo@cowtech.it>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Diffstat (limited to 'doc/api/util.md')
-rw-r--r-- | doc/api/util.md | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/doc/api/util.md b/doc/api/util.md index 9b9c01a4cc2..fecd6d341f3 100644 --- a/doc/api/util.md +++ b/doc/api/util.md @@ -1593,6 +1593,37 @@ Returns the `string` after replacing any surrogate code points (or equivalently, any unpaired surrogate code units) with the Unicode "replacement character" U+FFFD. +## `util.transferableAbortController()` + +<!-- YAML +added: REPLACEME +--> + +> Stability: 1 - Experimental + +Creates and returns an {AbortController} instance whose {AbortSignal} is marked +as transferable and can be used with `structuredClone()` or `postMessage()`. + +## `util.transferableAbortSignal(signal)` + +<!-- YAML +added: REPLACEME +--> + +> Stability: 1 - Experimental + +* `signal` {AbortSignal} +* Returns: {AbortSignal} + +Marks the given {AbortSignal} as transferable so that it can be used with +`structuredClone()` and `postMessage()`. + +```js +const signal = transferableAbortSignal(AbortSignal.timeout(100)); +const channel = new MessageChannel(); +channel.port2.postMessage(signal, [signal]); +``` + ## `util.types` <!-- YAML |