@nyaomaru/divider
    Preparing search index...

    Function dividerLoop

    • Divides input into chunks of specified size with optional configuration.

      This function provides a way to split input into equal-sized chunks with additional control:

      • Can specify starting offset for the chunking
      • Can limit the maximum number of chunks produced
      • Supports both string and array inputs
      • When maxChunks is specified, remaining content is merged into the last chunk

      Type Parameters

      • T extends string | string[]

      Parameters

      • input: T

        String or array of strings to divide into chunks

      • size: number

        Size of each chunk

      • Optionaloptions: DividerLoopOptions

        Configuration options for chunking behavior

        • Optionalexclude?: DividerExcludeMode

          Controls how empty or whitespace segments are handled

        • Optionalflatten?: boolean

          If true, flattens nested arrays into a single array

        • OptionalmaxChunks?: number

          Maximum number of chunks to produce

        • OptionalstartOffset?: number

          Starting position for the division (0-based)

        • Optionaltrim?: boolean

          If true, trims whitespace from each divided segment

      Returns DividerResult<T>

      Array of chunks based on input type and options

      dividerLoop("abcdef", 2) // returns ["ab", "cd", "ef"]
      dividerLoop("abcdef", 2, { maxChunks: 2 }) // returns ["ab", "cdef"]