UNPKG

@mondaydotcomorg/atp-compiler

Version:

Production-ready compiler for transforming async iteration patterns into resumable operations with checkpoint-based state management

23 lines (20 loc) 654 B
import { BatchPauseExecutionError } from './errors.js'; import type { BatchCallInfo } from '../types.js'; import { nextSequenceNumber, getCachedResult, getCallSequenceNumber, } from '@mondaydotcomorg/atp-runtime'; export async function batchParallel<T>( batchCalls: BatchCallInfo[], parallelId: string ): Promise<T[]> { const currentSequence = getCallSequenceNumber(); const cachedResult = getCachedResult(currentSequence); if (cachedResult !== undefined) { nextSequenceNumber(); return cachedResult as T[]; } const sequenceForPause = nextSequenceNumber(); throw new BatchPauseExecutionError(batchCalls, parallelId, sequenceForPause); }