Skip to content

processTextFactory

processTextFactory<T>(handlers): TextProcessor<T>

Defined in: text/process-text-factory.ts:56

Factory function to create a 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

TextProcessor<T>

A function that processes text based on the specified options.

Example

const handlers = {
toUpperCase: (text: string) => text.toUpperCase(),
addExclamation: (text: string) => text + "!",
};
const processText = processTextFactory(handlers);
const result = processText("hello", { toUpperCase: true, addExclamation: true });
console.log(result); // Outputs: "HELLO!"