Interface MwString

Type definitions for the methods of mw.String.

Note that the relevant object is not part of WpLibExtra (the interface is available in the npm package).

Hierarchy

  • MwString

Methods

  • Calculate the byte length of a string (accounting for UTF-8).

    Parameters

    • str: string

    Returns number

  • Like String#charAt, but return the pair of UTF-16 surrogates for characters outside of BMP.

    Parameters

    • string: string
    • offset: number

      Offset to extract the character.

    • Optional backwards: boolean

      Use backwards direction to detect UTF-16 surrogates, defaults to false.

    Returns string

  • Calculate the character length of a string (accounting for UTF-16 surrogates).

    Parameters

    • str: string

    Returns number

  • Lowercase the first character. Support UTF-16 surrogates for characters outside of BMP.

    Parameters

    • string: string

    Returns string

  • Utility function to trim down a string, based on byteLimit and given a safe start position. It supports insertion anywhere in the string, so "foo" to "fobaro" if limit is 4 will result in "fobo", not "foba". Basically emulating the native maxlength by reconstructing where the insertion occurred.

    Parameters

    • safeVal: string

      Known value that was previously returned by this function, if none, pass empty string.

    • newVal: string

      New value that may have to be trimmed down.

    • byteLimit: number

      Number of bytes the value may be in size.

    • Optional filterFunction: ((val) => number)

      Function to call on the string before assessing the length.

        • (val): number
        • Parameters

          • val: string

          Returns number

    Returns {
        newVal: string;
        trimmed: boolean;
    }

    • newVal: string
    • trimmed: boolean
  • Utility function to trim down a string, based on codePointLimit and given a safe start position. It supports insertion anywhere in the string, so "foo" to "fobaro" if limit is 4 will result in "fobo", not "foba". Basically emulating the native maxlength by reconstructing where the insertion occurred.

    Parameters

    • safeVal: string

      Known value that was previously returned by this function, if none, pass empty string.

    • newVal: string

      New value that may have to be trimmed down.

    • codePointLimit: number

      Number of characters the value may be in size.

    • Optional filterFunction: ((val) => number)

      Function to call on the string before assessing the length.

        • (val): number
        • Parameters

          • val: string

          Returns number

    Returns {
        newVal: string;
        trimmed: boolean;
    }

    • newVal: string
    • trimmed: boolean
  • Uppercase the first character. Support UTF-16 surrogates for characters outside of BMP.

    Parameters

    • string: string

    Returns string

Generated using TypeDoc