UNPKG

tty-strings

Version:

Tools for working with strings displayed in the terminal

20 lines 656 B
/** * Get the length of a string in grapheme clusters. ANSI escape codes will be ignored. * * @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 * ```ts * import { stringLength } from 'tty-strings'; * * // '🏳️‍🌈'.length === 6 * const len = stringLength('🏳️‍🌈'); // 1 * ``` * * @param string - Input string to measure. * @returns The length of the string in graphemes. */ export default function stringLength(string: string): number; //# sourceMappingURL=stringLength.d.ts.map