- constructor(
- workerScript: string,
- workerOptions: WorkerOptions = {
- workerStartDelay: WorkerConstants.DEFAULT_WORKER_START_DELAY,
- elementStartDelay: WorkerConstants.DEFAULT_ELEMENT_START_DELAY,
- poolMinSize: WorkerConstants.DEFAULT_POOL_MIN_SIZE,
- poolMaxSize: WorkerConstants.DEFAULT_POOL_MAX_SIZE,
- elementsPerWorker: WorkerConstants.DEFAULT_ELEMENTS_PER_WORKER,
- poolOptions: {},
- messageHandler: () => {
- /* This is intentional */
- },
+ constructor(workerScript: string, workerOptions: WorkerOptions) {
+ if (workerScript === null || workerScript === undefined) {
+ throw new Error('Worker script is not defined');
+ }
+ if (typeof workerScript === 'string' && workerScript.trim().length === 0) {
+ throw new Error('Worker script is empty');
+ }
+ if (!existsSync(workerScript)) {
+ throw new Error('Worker script file does not exist');