RSX Code Reference
    Preparing search index...
    • rsx
    • FormattingUtility

    Class FormattingUtility

    The FormattingUtility class provides utility functions for formatting text.

    Index
    defaultNumberDigits: 6

    The default number of digits to use for formatting numbers and vectors.

    emojiMap: Map<string, string>

    A map from text based smiley to emoji.

    knownEmojis: Set<string>

    A set of all emojis registered manually with RSX.

    • Converts a symbolicName to a string usable for a title in the UI.

      Parameters

      • symbolicName: string

      Returns string

      This essentially splits a PascalCaseString into a human readable title in the format Pascal Case String.

    • Converts text-based smilies to emojis.

      Parameters

      • text: string

      Returns string

      This method whitespace trims the input and end of the string.

    • Decodes the HTML encoded characters.

      Parameters

      • value: string

        The HTML encoded string

      Returns string

      This method only support the XML1/HTML1 standard, not the full range of HTML5 entities.

    • Escapes the HTML characters in text and replaces them with HTML entities.

      Parameters

      • text: string

        The string containing HTML.

      Returns string

      This converts a string in the form <b>Bold</b> to &lt;Bold&gt;.

    • Formats a byte length with "kB", "MB" or "GB" suffixes.

      Parameters

      • length: number

        The length to be formatted

      Returns string

      a string with the formatted byte length

    • Formats a duration in seconds using days, hours, minutes, and seconds.

      Parameters

      • elapsedSeconds: number

        The non-negative duration to format, in seconds.

      • OptionalshortForm: boolean

        True to abbreviate unit names.

      Returns string

      The formatted duration without relative-date direction words.

    • Formats the number value using the format, an optional suffix can be appended.

      Parameters

      • format: string

        The format, e.g. ##000.00

      • value: number

        The number to format.

      • Optionalsuffix: string

        The suffix to append.

      Returns string

      the formatted value.

    • Formats the given date object using relative dates.

      The formatting is done using the following logic:

      • If the the in the past:

        • If the date is less then 1 minute ago, it would return "Just now".
        • If in the order of minutes, it should return "X minutes ago"
        • If in the order of hours, it should return "X hours ago"
        • Then the scale goes to days, months and finally up to years.
      • If the the in the future:

        • If in the order of minutes, it should return "In X minutes"
        • If in the order of hours, it should return "In X hours"
        • If above 24h, it retuns a short date string.

      Parameters

      • date: string | Date

        The date to be formatted.

      • Optionalreference: string | Date

        The date to use as reference. Optional, and if not set will fallback to the current date.

      • OptionalupperCase: boolean

        True to uppercase the first character.

      • OptionaluseJustNow: boolean

        True to return "just now" for dates less than one minute ago.

      Returns string

    • Converts a name of an identifier (such as a field or a property) into a human readable name.

      Parameters

      • input: string

        Identifier to convert.

      Returns string

      Human readable name with spaces.

      This is an expensive API as the parsing handled reserved words such as float2x2. It's important to cache the result where possible.

    • Determines if the text is an emoji.

      Parameters

      • text: string

      Returns boolean

    • Determines if the specified email is a valid email adress in the format [email protected].

      Parameters

      • email: string

        The email address to validate

      Returns boolean

    • Removes all HTML tags from the input value.

      Parameters

      • value: string

      Returns string

    • Removes all special characters and white-space from the value and replaces these characters with invalid.

      Parameters

      • value: string
      • Optionalinvalid: string

      Returns string