https://github.com/luochen1990/easy-worker-threads
A lightweight & promise style wrapper of nodejs worker_threads
https://github.com/luochen1990/easy-worker-threads
Last synced: 10 months ago
JSON representation
A lightweight & promise style wrapper of nodejs worker_threads
- Host: GitHub
- URL: https://github.com/luochen1990/easy-worker-threads
- Owner: luochen1990
- Created: 2019-10-11T10:10:21.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2019-10-11T10:20:16.000Z (over 6 years ago)
- Last Synced: 2025-07-09T14:48:33.966Z (12 months ago)
- Language: JavaScript
- Homepage:
- Size: 1.95 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
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 easyWorker = require('easy-worker-threads')
const fib = (n) => {
if (n < 2) { return n } else { return fib(n-1) + fib(n-2) }
}
easyWorker.makeServiceFrom(fib)
```