iaptic-js
    Preparing search index...

    Class UtilsInternal

    Utility functions for the Iaptic library

    Index

    Constructors

    Methods

    • Base64 encode a string with fallbacks for different environments

      Parameters

      • str: string

        String to encode

      Returns string

      Base64 encoded string

      Handles non-ASCII characters and provides fallbacks for older browsers and Node.js environments

    • Internal

      Build a URL with query parameters

      Parameters

      • baseUrl: string

        Base URL without query parameters

      • params: Record<string, string>

        Object containing query parameters

      Returns string

      Complete URL with encoded query parameters

      Handles URL encoding and removes undefined/null parameters

    • Format an ISO 8601 period string into human-readable English

      Parameters

      • period: string

        ISO 8601 duration string

      Returns string

      Human-readable period string

      Utils.formatBillingPeriodEN('P1M') // Returns "Monthly"
      Utils.formatBillingPeriodEN('P3M') // Returns "Every 3 months"
      Utils.formatBillingPeriodEN('P1Y') // Returns "Yearly"
    • Format a currency amount from micros with proper localization

      Parameters

      • amountMicros: number

        Amount in micros (1/1,000,000 of currency unit)

      • currency: string

        ISO 4217 currency code (e.g., 'USD', 'EUR')

      Returns string

      Formatted currency string

      Utils.formatCurrency(1990000, 'USD') // Returns "$1.99"
      Utils.formatCurrency(1000000, 'EUR') // Returns "€1"
    • Internal

      Get and parse a JSON item from localStorage

      Type Parameters

      • T

      Parameters

      • key: string

        Storage key

      Returns T | null

      Parsed value or null if not found/invalid

    • Internal

      Get a string item from localStorage

      Parameters

      • key: string

        Storage key

      Returns string | null

      String value or null if not found

    • Internal

      Remove an item from localStorage

      Parameters

      • key: string

        Storage key

      Returns boolean

      true if successful, false if removal failed

    • Internal

      Store a JSON-serializable value in localStorage

      Parameters

      • key: string

        Storage key

      • value: any

        Value to store

      Returns boolean

      true if successful, false if storage failed

    • Internal

      Store a string value in localStorage

      Parameters

      • key: string

        Storage key

      • value: string

        String to store

      Returns boolean

      true if successful, false if storage failed