easy-worker-threads

0.0.1 • Public • Published

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)

Package Sidebar

Install

npm i easy-worker-threads

Weekly Downloads

0

Version

0.0.1

License

Apache-2.0

Unpacked Size

4.17 kB

Total Files

4

Last publish

Collaborators

  • luochen1990