//#region src/libs/formatters.ts
/**
* Formats bytes to a more readable format
*
* @see https://stackoverflow.com/a/18650828/1624255
*/
var formatBytes = (bytes, decimals = 2) => {
	if (!+bytes) return "0 Bytes";
	const k = 1024;
	const dm = decimals < 0 ? 0 : decimals;
	const sizes = [
		"B",
		"KiB",
		"MiB",
		"GiB",
		"TiB",
		"PiB",
		"EiB",
		"ZiB",
		"YiB"
	];
	const i = Math.floor(Math.log(bytes) / Math.log(k));
	return `${Number.parseFloat((bytes / Math.pow(k, i)).toFixed(dm))}${sizes[i]}`;
};
/**
* Formats milliseconds to seconds and appends an "s" if more than one second
* else returns ms appended to the number
*/
var formatMs = (ms, decimals = 2) => {
	if (ms > 1e3) return (ms / 1e3).toFixed(decimals) + "s";
	return ms + "ms";
};
//#endregion
export { formatBytes, formatMs };

//# sourceMappingURL=formatters.js.map