Vinyl
    Preparing search index...

    Function truncate

    • If the given string is greater than a max length, truncate the string with an indicator. Example: truncate('a very long string', 10) // 'a very ...'

      Type Parameters

      Parameters

      • str: T

        A nullable string.

      • maxLength: number
      • indicator: string = '…'

        The string to indicate there was truncation, default is an ellipses … (U+2026)

      Returns string | T

      Returns the truncated string, or the nullish value if str is nullish.