Merge pull request #302 from j0k3r/bugfix/reponse-size-two-decimal

Fix rounding response size
This commit is contained in:
Anoop M D 2023-10-04 03:32:30 +05:30 committed by GitHub
commit 72a5f05009
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 2 deletions

View File

@ -19,7 +19,7 @@ Libraries we use
### Dependencies ### Dependencies
You would need [Node v14.x or the latest LTS version](https://nodejs.org/en/) and npm 8.x. We use npm workspaces in the project You would need [Node v18.x or the latest LTS version](https://nodejs.org/en/) and npm 8.x. We use npm workspaces in the project
### Lets start coding ### Lets start coding

View File

@ -7,7 +7,7 @@ const ResponseSize = ({ size }) => {
if (size > 1024) { if (size > 1024) {
// size is greater than 1kb // size is greater than 1kb
let kb = Math.floor(size / 1024); let kb = Math.floor(size / 1024);
let decimal = ((size % 1024) / 1024).toFixed(2) * 100; let decimal = Math.round(((size % 1024) / 1024).toFixed(2) * 100);
sizeToDisplay = kb + '.' + decimal + 'KB'; sizeToDisplay = kb + '.' + decimal + 'KB';
} else { } else {
sizeToDisplay = size + 'B'; sizeToDisplay = size + 'B';