feat: prevent non-integer bases

Signed-off-by: Corentin Thomasset <corentin.thomasset74@gmail.com>
This commit is contained in:
Corentin Thomasset 2020-06-07 19:06:07 +02:00 committed by Corentin THOMASSET
parent 0bf13326c8
commit 45112d1b33
2 changed files with 23 additions and 7 deletions

View file

@ -24,8 +24,13 @@ const formatBytes = (bytes, decimals = 2) => {
return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + ' ' + sizes[i];
}
const isInt = (value) => {
return !isNaN(value) && ((x) => (x | 0) === x)(parseFloat(value))
}
export {
copyToClipboard,
fileIsImage,
formatBytes
formatBytes,
isInt
}