/** * Return a fresh ArrayBuffer containing exactly the bytes in `view`. * * Worker outputs must not transfer buffers that might be owned by a WASM * binding or by a larger shared packet. A fresh JS-owned buffer gives * postMessage() exclusive ownership without detaching unrelated memory. */ export function toOwnedArrayBuffer(view: Uint8Array): ArrayBuffer { const copy = new Uint8Array(view.byteLength); copy.set(view); return copy.buffer; }