Centaurus
Web worker interface. Simplified.
// load upconst Centaurus = ; // create worker, pass path to our workerlet C = 'https://unpkg.com/centaurus/dist/centaurus.worker.min.js'; // load umd scripts, be it lodash, whatever.C ;
Notes
How does it work?
- All
main-thread
toworker-thread
communications use promises. - UUIDv4 & Maps are used to identify incoming & outgoing messages.
serialize-javascript
is used to serialize all messages.
How do I create global variable assignments within the worker?
Yes. Just assign self.whatever
inside your functions.
And yes, your other functions can use them also.
C ;
Can I pass parameters?
Yes, please see the top-most example.
Can I return results?
Oh yes you can, you're unstoppable.
What types can we pass to the Worker?
- Everything here @ https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm
License
Attribution 4.0 International (CC BY 4.0)
- https://creativecommons.org/licenses/by/4.0/
- https://creativecommons.org/licenses/by/4.0/legalcode.txt