UNPKG

@adyen/adyen-platform-experience-web

Version:

![Platform Experience header](https://github.com/Adyen/adyen-platform-experience-web/assets/7926613/18094965-9e01-450e-8dc9-ea84e6b22c2b)

23 lines (22 loc) 648 B
import { clamp as a } from "../value/number.js"; const n = 3, o = (t) => t <= 1 ? 0 : Math.floor(Math.log(t) / Math.log(1024)), c = (t) => { let r = 0, e = Math.max(0, Math.round(t)); return e > 999 && (r = a(1, o(e), n), e = Math.round(Number((e / 1024 ** r).toPrecision(3)) * 10) / 10), { scale: r, size: e }; }, i = (t) => { const { scale: r, size: e } = c(t); switch (r) { case 0: return `${e} byte${e === 1 ? "" : "s"}`; case 1: return `${e} KB`; case 2: return `${e} MB`; case 3: return `${e} GB`; } }; export { o as getByteScale, c as getFileSize, i as getHumanReadableFileSize };