/** * Thin high-level helpers layered on top of the explicit worker primitives. * * @module bquery/concurrency */ import type { ParallelCollectionOptions, ParallelMapHandler, ParallelMapOptions, ParallelOptions, ParallelPredicateHandler, ParallelReduceHandler, ParallelResults, ParallelTask, TaskRunOptions } from './types'; /** * Executes multiple standalone tasks in parallel using a bounded worker pool. * * @example * ```ts * import { parallel } from '@bquery/bquery/concurrency'; * * const results = await parallel([ * { handler: (value: number) => value * 2, input: 5 }, * { handler: ({ a, b }: { a: number; b: number }) => a + b, input: { a: 1, b: 2 } }, * ]); * ``` */ export declare function parallel(tasks: TTasks, options?: ParallelOptions): Promise>; /** * Executes tasks in sequential batches while each batch still uses parallel workers. * * This adapts `threadts-universal`'s batch helper to bQuery without colliding * with the reactive module's existing `batch()` export. * * @example * ```ts * import { batchTasks } from '@bquery/bquery/concurrency'; * * const results = await batchTasks( * [ * { handler: (value: number) => value * 2, input: 1 }, * { handler: (value: number) => value * 2, input: 2 }, * { handler: (value: number) => value * 2, input: 3 }, * ], * 2 * ); * ``` */ export declare function batchTasks(tasks: TTasks, batchSize?: number, options?: ParallelOptions): Promise>; /** * Maps an array in parallel using optional chunking on top of `createTaskPool()`. * * @example * ```ts * import { map } from '@bquery/bquery/concurrency'; * * const results = await map([1, 2, 3], (value, index) => value + index, { * batchSize: 2, * concurrency: 2, * }); * ``` */ export declare function map(values: readonly TInput[], mapper: ParallelMapHandler, options?: ParallelMapOptions): Promise; /** * Filters an array in parallel using a standalone predicate with optional chunking. */ export declare function filter(values: readonly TInput[], predicate: ParallelPredicateHandler, options?: ParallelCollectionOptions): Promise; /** * Returns whether at least one array item matches a standalone predicate. * * The current implementation evaluates predicate chunks explicitly and reduces * the final boolean result on the main thread instead of using hidden globals * or speculative worker cancellation. */ export declare function some(values: readonly TInput[], predicate: ParallelPredicateHandler, options?: ParallelCollectionOptions): Promise; /** * Returns whether every array item matches a standalone predicate. * * The current implementation evaluates predicate chunks explicitly and reduces * the final boolean result on the main thread instead of using hidden globals * or speculative worker cancellation. */ export declare function every(values: readonly TInput[], predicate: ParallelPredicateHandler, options?: ParallelCollectionOptions): Promise; /** * Finds the first array item that matches a standalone predicate. */ export declare function find(values: readonly TInput[], predicate: ParallelPredicateHandler, options?: ParallelCollectionOptions): Promise; /** * Reduces an array inside one isolated worker while preserving standard * left-to-right accumulator semantics. */ export declare function reduce(values: readonly TInput[], reducer: ParallelReduceHandler, initialValue: TAccumulator, options?: TaskRunOptions): Promise; //# sourceMappingURL=high-level.d.ts.map