Skip to main content

Function: step()

step<TInput, TOutput>(fn, name?): Processable<TInput, TOutput>

Defined in: packages/core/src/pipeline/helpers.ts:59

Wrap a plain function as a Processable for use in pipelines. This is a readable helper that makes intent clear.

Type Parameters

TInput

TInput

Input type for the function

TOutput

TOutput

Output type from the function

Parameters

fn

(input) => TOutput | Promise<TOutput>

Function to wrap

name?

string

Optional name for debugging and tracing

Returns

Processable<TInput, TOutput>

Processable that executes the function

Example

const calculateStats = step((post: BlogPost) => ({
...post,
wordCount: post.content.split(/\s+/).length
}), 'calculateStats');

const myPipeline = pipeline(
validateInput,
calculateStats,
saveToDatabase
);