UNPKG

tty-strings

Version:

Tools for working with strings displayed in the terminal

78 lines 3.43 kB
/** * Base grapheme break properties */ export declare const GBProps: { readonly None: 0; readonly CR: 1; readonly LF: 2; readonly Control: 3; readonly Extend: 4; readonly ZWJ: 5; readonly RI: 6; readonly Prepend: 7; readonly SpacingMark: 8; readonly L: 9; readonly V: 10; readonly T: 11; readonly LV: 12; readonly LVT: 13; readonly ExtendedPictographic: 14; }; export declare const Emoji_Modifier = 128; /** * Indic conjunct break properties */ export declare const InCBProps: { readonly Extend: 16; readonly Linker: 32; readonly Consonant: 64; }; /** * Get the grapheme cluster break property of a given Unicode code point * * @remarks * Properties are derived from {@link https://unicode.org/Public/16.0.0/ucd/auxiliary/GraphemeBreakProperty.txt} * Extended_Pictographic and Emoji_Modifier values are derived from {@link https://unicode.org/Public/16.0.0/ucd/emoji/emoji-data.txt} * InCB properties are derived from {@link https://www.unicode.org/Public/16.0.0/ucd/DerivedCoreProperties.txt} * * @param code - unicode code point * @returns The grapheme cluster break property */ export declare function graphemeBreakProperty(code: number): number; /** * An approximation of whether a code point has the derived property `Grapheme_Base`. * The point is to be a quicker check than exaustively checking all code point ranges with the property, * since this check does not have to be super accurate. * The `Grapheme_Base` prop is derived from `[0..10FFFF] - Cc - Cf - Cs - Co - Cn - Zl - Zp - Grapheme_Extend` * * @remarks * This approximation returns false if the code point has the `Extend` grapheme break property, * (derived from {@link https://unicode.org/Public/16.0.0/ucd/auxiliary/GraphemeBreakProperty.txt}) * with the exception of the 5 code points `1F3FB - 1F3FF5` that also have the `Emoji_Modifier` property * (derived from {@link https://unicode.org/Public/16.0.0/ucd/emoji/emoji-data.txt}). * Otherwise, returns false if the code point has a general category value of `Cf`, `Zl`, or `Zp`, derived from * {@link https://unicode.org/Public/16.0.0/ucd/extracted/DerivedGeneralCategory.txt}. * * @remarks * This implementation will not produce any false negatives (a response of `false` when the code point actually does * have the `Grapheme_Base` property), but it will produce false positives. All code points that produce * false positives will have a `General_Category` value of `Cn`, `Cs`, or `Co`. * * @param cp - code point to check * @param gbp - the grapheme break property of the code point * @returns `true` if the code point has the property `Grapheme_Base`, or `false` otherwise. */ export declare function isGraphemeBase(cp: number, gbp: number): boolean; /** * Determines if there is a cluster boundary between two grapheme cluster break property values * * @remarks * Rules are from {@link http://unicode.org/reports/tr29/#Grapheme_Cluster_Boundary_Rules} * * @param breakProps - grapheme break properties for characters preceeding `prev` * @param prev - grapheme break property of the previous character * @param next - grapheme break property of the next character * @returns Whether there is a cluster boundary between `prev` and `next` */ export declare function shouldBreak(breakProps: number[], prev: number, next: number): boolean; //# sourceMappingURL=graphemeBreak.d.ts.map