parentPort,
threadId
} from 'node:worker_threads'
-import type { MessageValue } from '../utility-types'
-import { AbstractWorker } from './abstract-worker'
-import type { WorkerOptions } from './worker-options'
-import type { TaskFunction, TaskFunctions } from './task-functions'
+import type { MessageValue } from '../utility-types.js'
+import { AbstractWorker } from './abstract-worker.js'
+import type { WorkerOptions } from './worker-options.js'
+import type { TaskFunction, TaskFunctions } from './task-functions.js'
/**
* A thread worker used by a poolifier `ThreadPool`.
taskFunctions: TaskFunction<Data, Response> | TaskFunctions<Data, Response>,
opts: WorkerOptions = {}
) {
- super(isMainThread, parentPort as MessagePort, taskFunctions, opts)
+ super(isMainThread, parentPort, taskFunctions, opts)
}
/** @inheritDoc */
protected readonly sendToMainWorker = (
message: MessageValue<Response>
): void => {
- this.port?.postMessage({ ...message, workerId: this.id })
+ this.port?.postMessage({
+ ...message,
+ workerId: this.id
+ } satisfies MessageValue<Response>)
}
/**