c2e45b657f
fixes https://github.com/TryGhost/Toolbox/issues/370 - we no longer need `bthreads` because we can use native `worker_threads` now we don't have to support Node 10 any longer - this allows us to clean up a dependency and stick with native libraries - the referenced node-sqlite3 issue should be fixed (or at least, we now maintain it so we can fix it if not)
21 lines
485 B
JavaScript
21 lines
485 B
JavaScript
const {parentPort} = require('worker_threads');
|
|
|
|
setInterval(() => { }, 10);
|
|
|
|
if (parentPort) {
|
|
parentPort.on('message', (message) => {
|
|
if (message === 'error') {
|
|
throw new Error('oops');
|
|
}
|
|
|
|
if (message === 'cancel') {
|
|
parentPort.postMessage('cancelled');
|
|
return;
|
|
}
|
|
|
|
// post the message back
|
|
parentPort.postMessage(`Worker received: ${message}`);
|
|
parentPort.postMessage('done');
|
|
});
|
|
}
|