@limetech/lime-elements
Version:
30 lines • 1.07 kB
TypeScript
/**
* Pure utility functions for search-within-diff functionality.
*/
/**
* Escape special regex characters in a search term so it can
* be used as a literal pattern in a RegExp constructor.
*
* @param term - the raw search string
* @returns regex-safe string
*/
export declare function escapeRegex(term: string): string;
/**
* Build a case-insensitive regex that captures the search term.
* Returns `null` when the term is empty.
*
* @param term - the raw search string
* @returns a RegExp with a single capture group, or null
*/
export declare function buildSearchRegex(term: string): RegExp | null;
/**
* Calculate the next match index when navigating forward or backward,
* wrapping around at the boundaries.
*
* @param currentIndex - current zero-based match index
* @param direction - +1 for next, -1 for previous
* @param total - total number of matches
* @returns the new match index
*/
export declare function navigateMatchIndex(currentIndex: number, direction: number, total: number): number;
//# sourceMappingURL=search-utils.d.ts.map