![GitHub last commit](https://camo.githubusercontent.com/77bca6435c2735f7489ffac6bc11adfc61ffacbcee46df419ddfa534061f4221/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6173742d636f6d6d69742f6c652d61722f77706f6c6c)
Worker poll use worker_threads
import { WPoll } from 'wpoll';
import path from 'path';
let wpoll = new WPoll<number>(path.resolve(__dirname, './worker.js'));
wpoll.init();
(async () => {
console.log(await wpoll.exec(100));
})();
import { WWorker } from 'wpoll';
new WWorker(async (message) => {
console.log(message);
return 5;
});
WPoll<T = void, P = void>
Name |
Parameter |
Type |
Description |
Constructor |
|
WPoll<T, P> |
|
|
workerFile |
string |
Path to worker file (absolute path preferred) |
|
props |
WPollProps |
Init Parameters |
init |
- |
- |
Init Workers. Must be called once |
exec |
T |
P |
Execute with parameters T and return P |
WWorker<T = void, P = void>
Name |
Parameter |
Type |
Description |
Constructor |
|
WWorker<T,P> |
|
|
onMessage |
(message: T) => Promise<P> | P |
callback on message received |