• Processes a single file using the specified engine and options.

    This function acts as a dispatcher, routing the file processing to the appropriate method of the AioTextProcessor class based on the provided engineName. It supports various text processing operations like finding matches, splitting, replacing, translating, purifying, analyzing, and summarizing.

    Parameters

    • processor: AioTextProcessor

      An instance of the AioTextProcessor class, which provides the text processing methods.

    • filepath: string

      The path to the file that needs to be processed.

    • engineName: AioTextProcessorMethods

      The name of the engine to use for processing. This corresponds to a method name in AioTextProcessor.

    • options: any

      An object containing options specific to the selected engine. For example, findMatch might use MatchOptions, split might use chunkSize, and replace or translate might use other custom options.

    Returns Promise<any>

    A Promise that resolves to the processed content of the file. The structure of the returned content depends on the engine used. For example, findMatch might return an array of matches, split might return an array of chunks, and others might return a string.

    Throws an error if an unsupported engine name is provided.

    const processor = new AioTextProcessor();
    const filepath = 'path/to/my/file.txt';
    const result = await processFile(processor, filepath, 'findMatch', { pattern: /hello/g });
    console.log(result); // Output: An array of matches found in the file.