@99devco/analytics - v3.0.0
    Preparing search index...
    • Calculates the byte size of a string using UTF-8 encoding.

      This function is used to determine the size of payloads before sending them to ensure they don't exceed browser limits for beacon requests.

      Parameters

      • str: string

        The string to calculate the byte size for

      Returns number

      The number of bytes the string occupies when encoded as UTF-8

      const size = sizeOf("Hello, World!"); // Returns 13
      const largeSize = sizeOf(JSON.stringify(largeObject));