👷♀️ node-inline-worker
Moves a node module into a Node.js Worker, automatically reflecting exported functions as asynchronous proxies.
You might already be familiar with the Workerize npm package, which is the web counterpart for this module. The feature list and API are the same:
- Bundles a tiny, purpose-built RPC implementation into your node app
- If exported module methods are already async, signature is unchanged
- Supports synchronous and asynchronous worker functions
- Works beautifully with async/await
Available for Node >=12
without runtime flags. Uses node's Worker Threads.
Install
npm install --save node-inline-worker
Usage
Pass a function to be executed in the Worker thread
const add = { // Pre-curried use console // Logs after 1 second console // Logs after 1 second // Direct invocation const sequence = await 10 console // logs `55`}