@jiminp/tooltool
    Preparing search index...

    Function getNextChunkLength

    • Calculates the optimal length for the next text chunk.

      Splits at the last separator within max_length, considering only separators in the latter half to avoid tiny chunks.

      Parameters

      • text: string

        The text to split.

      • max_length: number

        Maximum chunk length (positive safe integer).

      • separators: string[] = ...

        Split points in order of preference (default: ['\n', ' ', '.']).

      Returns number

      The calculated chunk length.

      If max_length is not a positive safe integer.