-
- /**
- * Gets the worker id.
- *
- * @param worker - The worker.
- * @param workerType - The worker type.
- * @returns The worker id.
- */
- private getWorkerId (
- worker: Worker,
- workerType: WorkerType
- ): number | undefined {
- if (workerType === WorkerTypes.thread) {
- return worker.threadId
- } else if (workerType === WorkerTypes.cluster) {
- return worker.id
- }
- }
-
- /**
- * Executes a function once at a time.
- */
-
- private once (
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
- fn: (...args: any[]) => void,
- context = this
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
- ): (...args: any[]) => void {
- let called = false
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
- return function (...args: any[]): void {
- if (!called) {
- called = true
- fn.apply(context, args)
- called = false
- }
- }
- }