dAppBooster
    Preparing search index...

    Function truncateStringInTheMiddle

    • Truncates a string in the middle by replacing the middle portion with an ellipsis.

      This function preserves the beginning and ending portions of the string while replacing the middle section with "..." when the string exceeds a certain length.

      Parameters

      • str: string

        The original string to truncate

      • strPositionStart: number

        Number of characters to preserve from the beginning

      • strPositionEnd: number

        Number of characters to preserve from the end

      Returns string

      The truncated string or the original if no truncation is needed

      // Truncate an Ethereum address
      truncateStringInTheMiddle("0x1234567890abcdef1234567890abcdef12345678", 8, 6);
      // Returns: "0x123456...345678"