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

    Function trimCodePointLength

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

      • OptionalfilterFunction: FilterFunction

        Function to call on the string before assessing the length.

      Returns StringTrimmed