• Highlight the matched characters of a source text.

    Type Parameters

    • T

    Parameters

    • source: string

      The text which should be highlighted.

    • indices: readonly number[]

      The indices of the matched characters. They must appear in increasing order and must be in bounds of the source.

    • fn: ((chunk) => T)

      The function to apply to the matched chunks.

        • (chunk): T
        • Parameters

          • chunk: string

          Returns T

    Returns (string | T)[]

    An array of unmatched and highlighted chunks.