@jupyterlab/coreutils
Version:
JupyterLab - Core Utilities
46 lines (45 loc) • 1.49 kB
TypeScript
/**
* The namespace for text-related functions.
*/
export declare namespace Text {
/**
* Convert a javascript string index into a unicode character offset
*
* @param jsIdx - The javascript string index (counting surrogate pairs)
*
* @param text - The text in which the offset is calculated
*
* @returns The unicode character offset
*/
function jsIndexToCharIndex(jsIdx: number, text: string): number;
/**
* Convert a unicode character offset to a javascript string index.
*
* @param charIdx - The index in unicode characters
*
* @param text - The text in which the offset is calculated
*
* @returns The js-native index
*/
function charIndexToJsIndex(charIdx: number, text: string): number;
/**
* Given a 'snake-case', 'snake_case', 'snake:case', or
* 'snake case' string, will return the camel case version: 'snakeCase'.
*
* @param str the snake-case input string.
*
* @param upper default = false. If true, the first letter of the
* returned string will be capitalized.
*
* @returns the camel case version of the input string.
*/
function camelCase(str: string, upper?: boolean): string;
/**
* Given a string, title case the words in the string.
*
* @param str the string to title case.
*
* @returns the same string, but with each word capitalized.
*/
function titleCase(str: string): string;
}