Offload (almost) any function to a worker thread
npm install workerfyDoes not work under some circumstances, because workerfy relies on being able to stringify the passed function.
Bound functions always return "function () { [native code] }" when being stringified.
Inline functions that use closured values won't work.
``js`
const a = 1;
workerfy(() => a + 1); // will not work
Methods that access this.
index.js
`js
async function parseScript(script) {
const workerfy = require('workerfy');
const parse = workerfy(require('some-js-parsing-library'));
const result = await parse(script);
}
`
node --experimental-worker index.js`