UNPKG

worker-factory

Version:

A little factory function to create a JSON-RPC based Web Worker implementation.

11 lines (8 loc) 386 B
// Bug #1: Safari does currently not support to use transferables. export const isSupportingTransferables = () => new Promise<boolean>((resolve) => { const arrayBuffer = new ArrayBuffer(0); const { port1, port2 } = new MessageChannel(); port1.onmessage = ({ data }) => resolve(data !== null); port2.postMessage(arrayBuffer, [arrayBuffer]); });