-/* eslint-disable @typescript-eslint/strict-boolean-expressions */
-
import { isMainThread, parentPort } from 'worker_threads'
import { AsyncResource } from 'async_hooks'
* @author [Alessandro Pio Ardizio](https://github.com/pioardi)
* @since 0.0.1
*/
+// eslint-disable-next-line @typescript-eslint/no-explicit-any
export class ThreadWorker<Data = any, Response = any> extends AsyncResource {
protected readonly maxInactiveTime: number
protected readonly async: boolean
protected run (
fn: (data: Data) => Response,
- value: { readonly data: Data, readonly id: number }
+ value: { readonly data: Data; readonly id: number }
): void {
try {
const res = fn(value.data)
protected runAsync (
fn: (data: Data) => Promise<Response>,
- value: { readonly data: Data, readonly id: number }
+ value: { readonly data: Data; readonly id: number }
): void {
fn(value.data)
.then(res => {