Drastically simplified worker threads, on node
wraps your code with a promise so you don't have to warry about a thing, just use
thread it and it will use
workers where can.
Choose any sync module from
npm and instead of
Caution: not all data types can be passed to Worker Thread, for example you just can't pass a function, read carefully what types are supported.
npm i thread-it
Under the hood
threadId uses holdUp so you can use the same options to find a free worker from queue.
options- options may contain:
Also you can set
THREAD_IT_COUNT env variable to workers count, if
0 it means disabled worker threads.
const threadIt = ;// init workers, depend on os.cpus()threadIt;const putout = ;const result = await ;// when you need to override options use;// terminate workers when no need anymorethreadIt;
- hold-up - setInterval with promises, counter and error handling
- currify - translate the evaluation of a function that takes multiple arguments into evaluating a sequence of functions, each with a single or more arguments.
- fullstore - functional variables.
- wraptile - translate the evaluation of a function that takes multiple arguments into evaluating a sequence of 2 functions, each with a any count of arguments.