verdaccio-ui/src/utils/file-size.ts
Juan Picado @jotadeveloper e6b53c0479
chore: migrate eslint@6.6.0 (#227)
* chore: migrate to eslint6

* chore: migrate to eslint6
2019-10-27 15:49:30 +01:00

14 lines
302 B
TypeScript

export default function fileSizeSI(
a: number,
b?: typeof Math,
c?: (p: number) => number,
d?: number,
e?: number
): string {
return (
((b = Math), (c = b.log), (d = 1e3), (e = (c(a) / c(d)) | 0), a / b.pow(d, e)).toFixed(2) +
' ' +
(e ? 'kMGTPEZY'[--e] + 'B' : 'Bytes')
);
}