UNPKG

@xec-sh/core

Version:

Universal shell execution engine

29 lines (28 loc) 1.76 kB
import type { Command } from '../core/command.js'; import type { ExecutionResult } from '../core/result.js'; import type { CallableExecutionEngine } from '../types/engine.js'; import type { ProcessPromise, ExecutionEngine } from '../core/execution-engine.js'; export interface ParallelOptions { maxConcurrency?: number; stopOnError?: boolean; timeout?: number; onProgress?: (completed: number, total: number, succeeded: number, failed: number) => void; } export interface ParallelResult { results: (ExecutionResult | Error)[]; succeeded: ExecutionResult[]; failed: Error[]; duration: number; } export declare function parallel(commands: Array<string | Command | ProcessPromise>, engine: ExecutionEngine | CallableExecutionEngine, options?: ParallelOptions): Promise<ParallelResult>; export declare class ParallelEngine { private engine; constructor(engine: ExecutionEngine | CallableExecutionEngine); all(commands: Array<string | Command | ProcessPromise>, options?: ParallelOptions): Promise<ExecutionResult[]>; settled(commands: Array<string | Command | ProcessPromise>, options?: ParallelOptions): Promise<ParallelResult>; race(commands: Array<string | Command | ProcessPromise>): Promise<ExecutionResult>; map<T>(items: T[], fn: (item: T, index: number) => string | Command | ProcessPromise, options?: ParallelOptions): Promise<ParallelResult>; filter<T>(items: T[], fn: (item: T, index: number) => string | Command | ProcessPromise, options?: ParallelOptions): Promise<T[]>; some(commands: Array<string | Command | ProcessPromise>, options?: ParallelOptions): Promise<boolean>; every(commands: Array<string | Command | ProcessPromise>, options?: ParallelOptions): Promise<boolean>; }