UNPKG

@xylabs/threads

Version:

Web workers & worker threads as simple as a function call

16 lines 1.02 kB
import type { ModuleMethods, ModuleProxy, ProxyableFunction, Worker as WorkerType } from '../types/master.ts'; /** * Create a proxy function that forwards calls to a worker thread via postMessage. * @param worker - The worker to send messages to. * @param method - Optional method name for module-style workers. * @returns A proxied function that returns an `ObservablePromise`. */ export declare function createProxyFunction<Args extends any[], ReturnType>(worker: WorkerType, method?: string): ProxyableFunction<Args, ReturnType>; /** * Create a proxy module that maps method names to proxy functions forwarding calls to a worker. * @param worker - The worker to send messages to. * @param methodNames - The method names exposed by the worker module. * @returns A proxy object with methods matching the worker module's API. */ export declare function createProxyModule<Methods extends ModuleMethods>(worker: WorkerType, methodNames: string[]): ModuleProxy<Methods>; //# sourceMappingURL=invocation-proxy.d.ts.map