- constructor(
- workerScript: string,
- workerOptions: WorkerOptions = {
- workerStartDelay: Constants.WORKER_START_DELAY,
- elementStartDelay: Constants.ELEMENT_START_DELAY,
- poolMinSize: Constants.DEFAULT_WORKER_POOL_MIN_SIZE,
- poolMaxSize: Constants.DEFAULT_WORKER_POOL_MAX_SIZE,
- elementsPerWorker: Constants.DEFAULT_CHARGING_STATIONS_PER_WORKER,
- poolOptions: {},
- messageHandler: () => {
- /* This is intentional */
- },
+ constructor(workerScript: string, workerOptions: WorkerOptions) {
+ if (workerScript == null) {
+ throw new TypeError('Worker script is not defined');
+ }
+ if (typeof workerScript !== 'string') {
+ throw new TypeError('Worker script must be a string');
+ }
+ if (workerScript.trim().length === 0) {
+ throw new Error('Worker script is an empty string');
+ }
+ if (!existsSync(workerScript)) {
+ throw new Error('Worker script file does not exist');