UNPKG

1.49 kBTypeScriptView Raw
1/**
2 * The namespace for text-related functions.
3 */
4export declare namespace Text {
5 /**
6 * Convert a javascript string index into a unicode character offset
7 *
8 * @param jsIdx - The javascript string index (counting surrogate pairs)
9 *
10 * @param text - The text in which the offset is calculated
11 *
12 * @returns The unicode character offset
13 */
14 function jsIndexToCharIndex(jsIdx: number, text: string): number;
15 /**
16 * Convert a unicode character offset to a javascript string index.
17 *
18 * @param charIdx - The index in unicode characters
19 *
20 * @param text - The text in which the offset is calculated
21 *
22 * @returns The js-native index
23 */
24 function charIndexToJsIndex(charIdx: number, text: string): number;
25 /**
26 * Given a 'snake-case', 'snake_case', 'snake:case', or
27 * 'snake case' string, will return the camel case version: 'snakeCase'.
28 *
29 * @param str: the snake-case input string.
30 *
31 * @param upper: default = false. If true, the first letter of the
32 * returned string will be capitalized.
33 *
34 * @returns the camel case version of the input string.
35 */
36 function camelCase(str: string, upper?: boolean): string;
37 /**
38 * Given a string, title case the words in the string.
39 *
40 * @param str: the string to title case.
41 *
42 * @returns the same string, but with each word capitalized.
43 */
44 function titleCase(str: string): string;
45}