Skip to content

processLinesFactory

processLinesFactory<T>(handlers): LinesProcessor<T>

Defined in: text/process-lines-factory.ts:34

Factory function to create a line-by-line text processing function based on provided handlers.

Type Parameters

T

T extends HandlerMap

Parameters

handlers

T

An object mapping handler names to their corresponding functions.

Returns

LinesProcessor<T>

A function that processes an array of text lines based on the specified options.

Example

const handlers = {
toUpperCase: (text: string) => text.toUpperCase(),
addExclamation: (text: string) => text + "!",
};
const processLines = processLinesFactory(handlers);
const result = processLines(["hello", "world"], { toUpperCase: true, addExclamation: true });
console.log(result); // Outputs: ["HELLO!", "WORLD!"]