easy-worker-threads
v0.0.1
Published
A lightweight & promise style wrapper of worker-threads
Downloads
1
Maintainers
Readme
Easy Worker Threads
A lightweight & promise style wrapper of nodejs worker-threads.
Usage
install:
npm i easy-worker-threads
index.js:
const easyWorker = require('easy-worker-threads')
srv = easyWorker.useService('path/to/my-service.js')
Promise.all(list(range(10)).map(srv)).then((rs) => {
console.log(rs)
})
my-service.js:
const fib = (n) => {
if (n < 2) { return n } else { return fib(n-1) + fib(n-2) }
}
easyWorker.makeServiceFrom(fib)