if (!Number.isSafeInteger(this.workerOptions.elementsPerWorker)) {
throw new TypeError('Elements per worker must be an integer')
}
- if (this.workerOptions.elementsPerWorker <= 0) {
+ if (
+ typeof this.workerOptions.elementsPerWorker === 'number' &&
+ this.workerOptions.elementsPerWorker <= 0
+ ) {
throw new RangeError('Elements per worker must be greater than zero')
}
this.workerSet = new Set<WorkerSetElement>()
this.emitter?.emit(WorkerSetEvents.stopped, this.info)
this.started = false
this.emitter?.emitDestroy()
- this.emitter?.removeAllListeners()
}
/** @inheritDoc */
++workerSetElement.numberOfWorkerElements
// Add element sequentially to optimize memory at startup
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
- if (this.workerOptions.elementStartDelay! > 0) {
+ if (this.workerOptions.elementAddDelay! > 0) {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
- await sleep(randomizeDelay(this.workerOptions.elementStartDelay!))
+ await sleep(randomizeDelay(this.workerOptions.elementAddDelay!))
}
}