import type { ThreadArgs } from "../threads/ThreadPool"; import type { StatusCode } from "./statuses.js"; export type GetReturnType = T extends (...args: any[]) => ReturnType ? ReturnType : T; export type Awaited = T extends PromiseLike ? U : T; export type WorkerThreadFn = (...args: Args extends [...args: any[]] ? Args : [Args]) => Promise; export interface IThreadOptions { once?: boolean; } export interface IThread, Output> { /** * Executes the thread function and returns the result. * * @returns {(Promise)} */ send(...data: Args extends any[] ? Args : [...args: Args[]]): Promise; /** Terminates the thread */ terminate(): Promise; } export interface ThreadConstructor, Output> { constructor(src: string | URL, options: { type?: "module" | undefined; once?: boolean; id?: number; maxConcurrency?: number; }): IThread; constructor Output>(src: F, options: { type?: "module" | undefined; once?: boolean; id?: number; maxConcurrency?: number; }): F extends (...args: any[]) => Promise ? IThread, R> : IThread, GetReturnType>; constructor(src: URL | string, options: { type?: "module" | undefined; once?: boolean; id?: number; maxConcurrency?: number; }): IThread; }