Readarr/frontend/src/Utilities/Number/convertToBytes.js
Qstick 64a8d02f77
New: Server Side UI Filtering, Error Boundaries (#501)
Co-Authored-By: Mark McDowall <markus101@users.noreply.github.com>
2018-09-22 23:10:50 -04:00

15 lines
317 B
JavaScript

function convertToBytes(input, power, binaryPrefix) {
const size = Number(input);
if (isNaN(size)) {
return '';
}
const prefix = binaryPrefix ? 1024 : 1000;
const multiplier = Math.pow(prefix, power);
const result = size * multiplier;
return Math.round(result);
}
export default convertToBytes;