- constructor(workerScript: string, workerStartDelay: number = Constants.WORKER_START_DELAY) {
- this.workerScript = workerScript;
- this.workerStartDelay = workerStartDelay;
+ constructor (workerScript: string | undefined, 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')
+ }
+ this.workerScript = workerScript
+ this.workerOptions = workerOptions