easy-worker-threads

A lightweight & promise style wrapper of worker-threads

Usage no npm install needed!

<script type="module">
  import easyWorkerThreads from 'https://cdn.skypack.dev/easy-worker-threads';
</script>

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)