easy-worker-thread
[![build status][travis-image]][travis-url] [![David deps][david-image]][david-url]
More convenient to use worker thread using the tarn.js maintain thread pool
node 12+
Install
$ npm i easy-worker-thread --save
Usage
Attention
: The scope of the method is isolated for package and variable
const EasyWorkerThread = ; // reference tarn.js configconst config = min: 0 max: 5 // acquire promises are rejected after this many milliseconds // if a resource cannot be acquired acquireTimeoutMillis: 30000 // create operations are cancelled after this many milliseconds // if a resource cannot be acquired createTimeoutMillis: 30000 // destroy operations are awaited for at most this many milliseconds // new resources will be created after this timeout destroyTimeoutMillis: 5000 // free resouces are destroyed after this many milliseconds idleTimeoutMillis: 30000 // how often to check for idle resources to destroy reapIntervalMillis: 1000 // how long to idle after failed create before trying again createRetryIntervalMillis: 200 // If true, when a create fails, the first pending acquire is // rejected with the error. If this is false (the default) then // create is retried until acquireTimeoutMillis milliseconds has // passed. propagateCreateError: false; const easyWorkerThread = config; const _ = const foo = 'bar'; // The parameter need to be object for more arguments { const _ = // require again console; // undefined return 'bar';} await easyWorkerThread // 'bar'