mwbot-ts - v1.2.7
    Preparing search index...

    Function trimByteLength

    • 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.

      • OptionalfilterFunction: FilterFunction

        Function to call on the string before assessing the length.

      Returns StringTrimmed