Options
All
  • Public
  • Public/Protected
  • All
Menu

Namespace Text

The namespace for text-related functions.

Index

Functions

camelCase

  • camelCase(str: string, upper?: boolean): string
  • Given a 'snake-case', 'snake_case', 'snake:case', or 'snake case' string, will return the camel case version: 'snakeCase'.

    Parameters

    • str: string
    • Optional upper: boolean

    Returns string

    the camel case version of the input string.

charIndexToJsIndex

  • charIndexToJsIndex(charIdx: number, text: string): number
  • Convert a unicode character offset to a javascript string index.

    Parameters

    • charIdx: number

      The index in unicode characters

    • text: string

      The text in which the offset is calculated

    Returns number

    The js-native index

jsIndexToCharIndex

  • jsIndexToCharIndex(jsIdx: number, text: string): number
  • Convert a javascript string index into a unicode character offset

    Parameters

    • jsIdx: number

      The javascript string index (counting surrogate pairs)

    • text: string

      The text in which the offset is calculated

    Returns number

    The unicode character offset

titleCase

  • titleCase(str: string): string
  • Given a string, title case the words in the string.

    Parameters

    • str: string

    Returns string

    the same string, but with each word capitalized.

Generated using TypeDoc