/** * Zero-build worker task helpers. * * @module bquery/concurrency */ import type { CreateTaskWorkerOptions, RunTaskOptions, TaskWorker, WorkerTaskSource } from './types'; /** * Creates a reusable worker task handle around a standalone function. * * Pass an inline standalone function for the zero-build dynamic mode (which * relies on `new Function(...)` and therefore needs a relaxed CSP), or a * {@link WorkerModule} from `defineWorker()` for the CSP-safe module mode. * * @example * ```ts * import { createTaskWorker, defineWorker } from '@bquery/bquery/concurrency'; * * // dynamic mode (needs 'unsafe-eval') * const worker = createTaskWorker((value: number) => value * value, { name: 'square-worker' }); * const result = await worker.run(12); * worker.terminate(); * * // module mode (CSP-safe, no eval) * const heavy = defineWorker(new URL('./square.worker.ts', import.meta.url)); * const moduleWorker = createTaskWorker(heavy); * ``` */ export declare function createTaskWorker(source: WorkerTaskSource, options?: CreateTaskWorkerOptions): TaskWorker; /** * Executes a single task in a fresh worker and tears it down afterwards. * * Accepts either an inline standalone function (dynamic mode) or a * {@link WorkerModule} from `defineWorker()` (CSP-safe module mode). * * @example * ```ts * import { runTask } from '@bquery/bquery/concurrency'; * * const result = await runTask((value: number) => value * 2, 21); * ``` */ export declare function runTask(source: WorkerTaskSource, input: TInput, options?: RunTaskOptions): Promise; //# sourceMappingURL=task.d.ts.map