highlight-matches-utils
Version:
Utility functions to mark and/or highlight character matches in texts
33 lines (28 loc) • 746 B
Flow
// @flow
declare type SplitMatchesResult = Array<{|
isMatch: boolean,
str: string
|}>
declare module.exports: {
highlightChars<T>(
text: string,
chars: string,
matchesWrapper: (s: string, index: number, array: SplitMatchesResult) => T,
noMatchesWrapper?: (
s: string,
index: number,
array: SplitMatchesResult
) => T
): Array<T>,
highlightMatches<T>(
text: string,
matches: number[],
matchesWrapper: (s: string, index: number, array: SplitMatchesResult) => T,
noMatchesWrapper?: (
s: string,
index: number,
array: SplitMatchesResult
) => T
): Array<T>,
splitMatches(text: string, matches: number[]): SplitMatchesResult
}