UNPKG

@pdf-viewer/react

Version:

A react-pdf-viewer component for React and Next.js. Suitable for react-pdf document.

10 lines (9 loc) 291 B
function i(t, e) { if (t == 0) return "0 Bytes"; var o = 1e3, r = e || 2, a = ["Bytes", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"], B = Math.floor(Math.log(t) / Math.log(o)); return parseFloat((t / Math.pow(o, B)).toFixed(r)) + " " + a[B]; } export { i as formatFileSize };