requiret (Require Threads)
Require a module as a Worker Thread in Node.js
Requirements
- Node.js 10.5.0+
Install
npm install requiret
Demo (converting a sync function to an async function)
readfile.js (this is our thread)
const fs = //It must exports an async functionmodule{ const data = fs return data}
index.js
const requiret = const readfile =
Running
You must run node with the --experimental-worker
flag enabled.
node --experimental-worker index.js