🏗️ Run a module in a Web Worker.
See the code
Moves a module into a Web Worker, automatically reflecting exported functions as asynchronous proxies.
npm install --save workerize
Pass either a function or a string containing code.
worker.js:
let worker = workerize(`
export function add(a, b) {
// block for half a second to demonstrate asynchronicity
let start = Date.now();
while (Date.now()-start < 500);
return a + b;
}
`);
(async () => {
console.log('3 + 9 = ', await worker.add(3, 9));
console.log('1 + 2 = ', await worker.add(1, 2));
})();
Overall
Maintained
Code review
npm
Latest release
Releases this year
(top 24 of 42)
2,324 followers · starred Jan 2018
1,558 followers · starred Jan 2018
4,971 followers · starred Jun 2019
822 followers · starred Jan 2018
🏗️ Run a module in a Web Worker.
See the code
Moves a module into a Web Worker, automatically reflecting exported functions as asynchronous proxies.
npm install --save workerize
Pass either a function or a string containing code.
worker.js:
let worker = workerize(`
export function add(a, b) {
// block for half a second to demonstrate asynchronicity
let start = Date.now();
while (Date.now()-start < 500);
return a + b;
}
`);
(async () => {
console.log('3 + 9 = ', await worker.add(3, 9));
console.log('1 + 2 = ', await worker.add(1, 2));
})();
Overall
Maintained
Code review
npm
Latest release
Releases this year
(top 24 of 42)
2,324 followers · starred Jan 2018
1,558 followers · starred Jan 2018
4,971 followers · starred Jun 2019
822 followers · starred Jan 2018