util.transferableAbortSignal(signal)
稳定性: 1 - 实验
signal
<AbortSignal>- 返回: <AbortSignal>
将给定的 <AbortSignal> 标记为可转让,以便它可以与 structuredClone()
和 postMessage()
一起使用。
const signal = transferableAbortSignal(AbortSignal.timeout(100));
const channel = new MessageChannel();
channel.port2.postMessage(signal, [signal]);
Stability: 1 - Experimental
signal
<AbortSignal>- Returns: <AbortSignal>
Marks the given <AbortSignal> as transferable so that it can be used with
structuredClone()
and postMessage()
.
const signal = transferableAbortSignal(AbortSignal.timeout(100));
const channel = new MessageChannel();
channel.port2.postMessage(signal, [signal]);