Skip to main content

Interface: RecursiveLoopConfig<TInput, TOutput>

Defined in: packages/core/src/pipeline/types.ts:109

Configuration for recursive loop step. Body receives a recurse callback for processing nested structures.

Example

const config: RecursiveLoopConfig<Comment, ProcessedComment> = {
condition: (result, depth) => result.hasReplies && depth < 10,
body: async (comment, recurse) => {
const processed = await processComment(comment);
if (processed.replies) {
processed.replies = await Promise.all(processed.replies.map(recurse));
}
return processed;
},
maxIterations: 100
};

Type Parameters

TInput

TInput

Input type for each recursive call

TOutput

TOutput

Output type from recursive processing

Properties

body

body: (input, recurse) => TOutput | Promise<TOutput>

Defined in: packages/core/src/pipeline/types.ts:120

Processor for each recursive call. Receives input and recurse callback. The recurse callback allows processing nested data structures.

Parameters

input

TInput

recurse

(i) => Promise<TOutput>

Returns

TOutput | Promise<TOutput>


condition

condition: (result, depth) => boolean | Promise<boolean>

Defined in: packages/core/src/pipeline/types.ts:114

Legacy post-body observer. Receives the result and recursion depth. Its return value does not control recursion; the body calls recurse.

Parameters

result

TOutput

depth

number

Returns

boolean | Promise<boolean>


maxIterations?

optional maxIterations?: number

Defined in: packages/core/src/pipeline/types.ts:123

Maximum total iterations across all recursive calls combined