ivt
Version:
Ivt Components Library
43 lines (39 loc) • 1.26 kB
JavaScript
import { t as twMerge } from './bundle-mjs-CXmmFvYo.mjs';
function r(e) {
var t, f, n = "";
if ("string" == typeof e || "number" == typeof e) n += e;
else if ("object" == typeof e) if (Array.isArray(e)) {
var o = e.length;
for(t = 0; t < o; t++)e[t] && (f = r(e[t])) && (n && (n += " "), n += f);
} else for(f in e)e[f] && (n && (n += " "), n += f);
return n;
}
function clsx() {
for(var e, t, f = 0, n = "", o = arguments.length; f < o; f++)(e = arguments[f]) && (t = r(e)) && (n && (n += " "), n += t);
return n;
}
function cn(...inputs) {
return twMerge(clsx(inputs));
}
function formatBytes(bytes, opts = {}) {
const { decimals = 0, sizeType = "normal" } = opts;
const sizes = [
"Bytes",
"KB",
"MB",
"GB",
"TB"
];
const accurateSizes = [
"Bytes",
"KiB",
"MiB",
"GiB",
"TiB"
];
if (bytes === 0) return "0 Byte";
const i = Math.floor(Math.log(bytes) / Math.log(1024));
return `${(bytes / 1024 ** i).toFixed(decimals)} ${sizeType === "accurate" ? accurateSizes[i] ?? "Bytes" : sizes[i] ?? "Bytes"}`;
}
export { clsx as a, cn as c, formatBytes as f };
//# sourceMappingURL=utils-BDcRwQMd.mjs.map