You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
16 lines
317 B
16 lines
317 B
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;
|