Skip to content

withTransfer<TValue>

Marks a result to transfer some of its objects (an ArrayBuffer, a MessagePort, an OffscreenCanvas…) instead of copying them. A transferred object is unusable on the sending side afterwards.

Import:

import { withTransfer } from '@mnaoumov/obsidian-lib/worker-protocol';

Signature:

function withTransfer(value: TValue, transfer: readonly Transferable[]): TransferredValue<TValue>

Parameters:

Parameter Type Description
value TValue The value.
transfer readonly Transferable[] The objects inside it to transfer.

Returns: TransferredValue<TValue> — The wrapped value.


Links to this page: