How to use the threads/worker.Transfer function in threads

To help you get started, we’ve selected a few threads examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github higlass / higlass / app / scripts / data-fetchers / bam-fetcher-worker.js View on Github external
// console.log('positions:', positions);
  // console.log('colors:', colors);

  const objData = {
    rows,
    positionsBuffer,
    colorsBuffer,
    xScaleDomain: domain,
    xScaleRange: scaleRange,
  };

  // eslint-disable-next-line
  console.log('renderSegments took', performance.now() - t1);

  // Fritz: why are the two buffers returned twice?
  return Transfer(objData, [positionsBuffer, colorsBuffer]);
};
github ceresimaging / fast-lzw / src / worker.js View on Github external
decompressAll: async (_) => {
    const typedArrays = await decompressAll(_)
    return Transfer(typedArrays, typedArrays.map(typedArray => typedArray.buffer))
  },
})