UNPKG

@scalar/api-client

Version:

the open source API testing client

11 lines (10 loc) 397 B
const n = (t, o = 2) => { if (!+t) return "0 Bytes"; const r = 1024, e = o < 0 ? 0 : o, B = ["B", "KiB", "MiB", "GiB", "TiB", "PiB", "EiB", "ZiB", "YiB"], i = Math.floor(Math.log(t) / Math.log(r)); return `${Number.parseFloat((t / Math.pow(r, i)).toFixed(e))}${B[i]}`; }, s = (t, o = 2) => t > 1e3 ? (t / 1e3).toFixed(o) + "s" : t + "ms"; export { n as formatBytes, s as formatMs };