UNPKG

tty-strings

Version:

Tools for working with strings displayed in the terminal

21 lines 892 B
/** * A generator function that splits a string into its component graphemes. Does not handle ANSI escape codes, * so make sure to remove them from input strings before calling this function. * * @remarks * This function is an implementation of UAX #29 grapheme cluster boundary splitting: * {@link https://www.unicode.org/reports/tr29/tr29-21.html#Grapheme_Cluster_Boundaries} * * @example * ```js * import { splitChars } from 'tty-strings'; * * // [...'à̰ḇ́ĉ̥'] -> ['a', '\u0300', '\u0330', 'b', '\u0341', '\u0331', 'c', '\u0302', '\u0325'] * const chars = [...splitChars('à̰ḇ́ĉ̥')]; // ['à̰', 'ḇ́', 'ĉ̥'] * ``` * * @param string - Input string to split. * @returns A generator that yields each grapheme in the input string. */ export default function splitChars(string: string): Generator<string, void>; //# sourceMappingURL=splitChars.d.ts.map