Routine
Inline, Promise based wrapper around JS Web Workers
yarn add worker-routine
Usage
Using async / await
:
; const inneficientSquare = { let total = 0; for let i = 0; i < n; i++ for let j = 0; j < n; j++ total++; return total;}; // spawns two workers running in separate threadsconst results = await Promiseall ; console;
Using Promise.then
:
; const multiply = a * b * c; ;