UNPKG

@visulima/string

Version:

Functions for manipulating strings.

35 lines (34 loc) 1.52 kB
import { e as IntervalArray } from "./packem_shared/types.d-CmNvyl4l.js"; /** * Escapes characters with special meaning in regular expressions. * @param char The string to escape. * @returns The escaped string. */ declare const escapeRegExp: (char: string) => string; /** * Checks if a number falls within any of the specified intervals. * @param number_ The number to check. * @param ranges An array of intervals [start, end]. * @returns True if the number is within any interval, false otherwise. */ declare const inRange: (number_: number, ranges: IntervalArray) => boolean; /** * Checks if a string contains Chinese characters (Han script). * @param char The string to check. * @returns True if the string contains Chinese characters, false otherwise. */ declare const hasChinese: (char: string) => boolean; /** * Checks if a string contains punctuation or space characters. * @param char The string to check. * @returns True if the string contains punctuation or space, false otherwise. */ declare const hasPunctuationOrSpace: (char: string) => boolean; /** * Finds all occurrences of a set of substrings within a source string and returns their start/end indices. * @param source The string to search within. * @param needles An array of strings to search for. * @returns An array of intervals [start, end] for each occurrence. */ declare const findStringOccurrences: (source: string, needles: string[]) => IntervalArray; export { escapeRegExp, findStringOccurrences, hasChinese, hasPunctuationOrSpace, inRange };