@trap_stevo/filetide
Version:
Revolutionizing real-time file transfer with seamless, instant communication across any device. Deliver files instantly, regardless of platform, and experience unparalleled speed and control in managing transfers. Elevate your file-sharing capabilities wi
71 lines (70 loc) • 1.74 kB
JavaScript
const {
HUDUtilityManager
} = require("@trap_stevo/legendarybuilderpronodejs-utilities");
class FileNetUtilityManager {
static convertSeconds(seconds) {
if (seconds === 0) return "0 s";
const units = [{
name: "y",
seconds: 60 * 60 * 24 * 365
}, {
name: "mo",
seconds: 60 * 60 * 24 * 30
}, {
name: "w",
seconds: 60 * 60 * 24 * 7
}, {
name: "d",
seconds: 60 * 60 * 24
}, {
name: "h",
seconds: 60 * 60
}, {
name: "m",
seconds: 60
}, {
name: "s",
seconds: 1
}];
let remainingSeconds = seconds;
let result = "";
for (const unit of units) {
const count = Math.floor(remainingSeconds / unit.seconds);
if (count > 0) {
result += `${count}${unit.name} `;
remainingSeconds %= unit.seconds;
}
}
return result.trim();
}
static getFormattedSize(size, dynamicUnits = true) {
if (!dynamicUnits) return `${size.toFixed(1)} B`;
const units = ["B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"];
let unitIndex = 0;
while (size >= 1024 && unitIndex < units.length - 1) {
size /= 1024;
unitIndex++;
}
return `${size.toFixed(2)} ${units[unitIndex]}`;
}
static getUnitData(size, dynamicUnits = true) {
if (!dynamicUnits) return {
current: size.toFixed(1),
unit: "B"
};
const units = ["B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"];
let unitIndex = 0;
while (size >= 1024 && unitIndex < units.length - 1) {
size /= 1024;
unitIndex++;
}
return {
current: size.toFixed(2),
unit: units[unitIndex]
};
}
}
module.exports = {
FileNetUtilityManager
};
;