adonis-forge
Version:
Bundle utils for AdonisJS
33 lines (32 loc) • 811 B
JavaScript
// src/utils/format.ts
var formatQuery = (data) => {
return Object.keys(data).reduce((total, key) => {
if (data[key]) {
total.push(`${key}=${data[key]}`);
}
return total;
}, []).join("&");
};
var easyBytes = (bytes) => {
if (!bytes) return "0B";
const gb = bytes / (1024 * 1024 * 1024);
const mb = bytes / (1024 * 1024);
if (gb >= 1) {
return gb.toFixed(2) + "GB";
}
return mb.toFixed(2) + "MB";
};
var privateEmail = (email) => {
if (!email) return "";
const [username, domain] = email.split("@");
const len = username.length;
const halfLen = Math.floor(len / 2);
const hidden = "*".repeat(halfLen);
return `${username.slice(0, halfLen)}${hidden}@${domain}`;
};
export {
formatQuery,
easyBytes,
privateEmail
};
//# sourceMappingURL=chunk-4VDVHUTC.js.map