0.0.1 • Published 5 years ago

easy-worker-threads v0.0.1

Weekly downloads
4
License
Apache-2.0
Repository
github
Last release
5 years ago

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)