Skip to content

Commit

Permalink
fix(round): round total stats always to two decimals
Browse files Browse the repository at this point in the history
  • Loading branch information
zaldih committed Oct 4, 2020
1 parent e32a4cc commit c3560bf
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions src/services/results.service.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { IFolder, IStats } from '@interfaces/index';

import { FOLDER_SORT } from '@core/constants/sort.result';

export class ResultsService {
Expand All @@ -23,13 +22,8 @@ export class ResultsService {
}, 0);

return {
spaceReleased: `${this.round(spaceReleased, 2)} GB`,
totalSpace: `${this.round(totalSpace, 2)} GB`,
spaceReleased: `${spaceReleased.toFixed(2)} GB`,
totalSpace: `${totalSpace.toFixed(2)} GB`,
};
}

private round(numb: number, decimals: number = 0): number {
const toRound = +(numb + 'e' + decimals);
return Number(Math.round(toRound) + 'e-' + decimals);
}
}

0 comments on commit c3560bf

Please sign in to comment.