UNPKG

@mlightcad/common

Version:

The common package provides shared utilities and base classes that are used across the RealDWG-Web ecosystem. This package contains fundamental components for color management, event handling, logging, performance monitoring, and file loading operations.

25 lines 938 B
var AcTrStringUtil = /** @class */ (function () { function AcTrStringUtil() { } /** * Converts a byte count to a human-readable string using KB, MB, or GB. * * @param bytes - The number of bytes. * @param decimals - Number of decimal places to include (default is 2). * @returns A formatted string with the appropriate unit. */ AcTrStringUtil.formatBytes = function (bytes, decimals) { if (decimals === void 0) { decimals = 2; } if (bytes === 0) return '0 B'; var k = 1024; var dm = Math.max(0, decimals); var sizes = ['B', 'KB', 'MB', 'GB', 'TB']; var i = Math.floor(Math.log(bytes) / Math.log(k)); var value = bytes / Math.pow(k, i); return "".concat(parseFloat(value.toFixed(dm)), " ").concat(sizes[i]); }; return AcTrStringUtil; }()); export { AcTrStringUtil }; //# sourceMappingURL=AcCmStringUtil.js.map