INNER CODE UNIT · TypeScript
executeParallel
Kong/volcano-agent-sdk · src/patterns.ts:3
export async function executeParallel(
stepsOrDict: any[] | Record<string, any>,
executeStep: (step: any) => Promise<StepResult>
): Promise<StepResult> {
const stepStart = Date.now();
if (Array.isArray(stepsOrDict)) {
const results = await Promise.all(stepsOrDict.map(s => executeStep(s)));
return {
parallelResults: results,
durationMs: Date.now() - stepStart,
};
} else {
const keys = Object.keys(stepsOrDict);
const promises = keys.map(key => executeStep(stepsOrDict[key]));
const results = await Promise.all(promises);
const parallel: Record<string, StepResult> = {};