Utility class providing static methods for string operations and formatting.

Contains helper functions for data formatting, size conversions, and other string manipulation tasks commonly needed in AutoCAD file processing.

AcTrStringUtil

1.0.0

Constructors

Methods

Constructors

Methods

  • Converts a byte count to a human-readable string using appropriate size units.

    Automatically selects the most appropriate unit (B, KB, MB, GB, TB) based on the size and formats the result with the specified number of decimal places.

    Parameters

    • bytes: number

      The number of bytes to format.

    • Optionaldecimals: number

      Number of decimal places to include in the result.

    Returns string

    A formatted string with the appropriate unit.

    import { AcTrStringUtil } from './AcCmStringUtil'

    // Format different byte sizes
    AcTrStringUtil.formatBytes(0) // "0 B"
    AcTrStringUtil.formatBytes(1024) // "1 KB"
    AcTrStringUtil.formatBytes(1024 * 1024) // "1 MB"
    AcTrStringUtil.formatBytes(1536, 1) // "1.5 KB"
    AcTrStringUtil.formatBytes(2048000, 0) // "2 MB"