@trap_stevo/vault-link
Version:
Unlock the ultimate gateway to secure file and directory access. VaultLink transforms your files into guarded, time-sensitive links—sealed, tamper-proof, and effortlessly shareable. Elevate your storage game with unparalleled precision and flexibility, tu
50 lines (49 loc) • 1.23 kB
JavaScript
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.parseTime = parseTime;
function parseTime(expiration) {
if (typeof expiration === "string") {
const regex = /(\d+)([smhdwyn]|ms|ns)/g;
expiration = expiration.replace(/\s+/g, "");
let totalSeconds = 0;
let match;
while ((match = regex.exec(expiration)) !== null) {
const value = parseInt(match[1]);
const unit = match[2];
switch (unit) {
case "ns":
totalSeconds += value / 1e9;
break;
case "ms":
totalSeconds += value / 1e3;
break;
case "s":
totalSeconds += value;
break;
case "m":
totalSeconds += value * 60;
break;
case "h":
totalSeconds += value * 3600;
break;
case "d":
totalSeconds += value * 86400;
break;
case "w":
totalSeconds += value * 604800;
break;
case "y":
totalSeconds += value * 31536000;
break;
default:
totalSeconds += 3600;
break;
}
}
return totalSeconds;
}
return expiration ? parseInt(expiration) : 1800;
}
;
;