UNPKG

worker-nodes

Version:

A library to run cpu-intensive tasks without blocking the event loop.

3 lines (2 loc) 164 B
const { parentPort, threadId } = require('worker_threads'); module.exports = (message) => threadId === 0 ? process.send(message) : parentPort.postMessage(message);