Skip to content

Commit

Permalink
fix: 🐛 fixed rounding issue for percent
Browse files Browse the repository at this point in the history
  • Loading branch information
WasiqB committed Sep 10, 2024
1 parent 2557743 commit 8ebae8c
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 13 deletions.
8 changes: 0 additions & 8 deletions .nycrc

This file was deleted.

7 changes: 3 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,13 @@
"release.patch": "pnpm release.ci patch",
"release.minor": "pnpm release.ci minor",
"release.major": "pnpm release.ci major",
"build": "rm -rf dist && tsc && cp -R src/templates dist/templates",
"clean": "rm -rf dist",
"build": "pnpm clean && tsc && cp -R src/templates dist/templates",
"dev": "pnpm build -w",
"test": "node ./test/test.js",
"new:test": "pnpm node ./src/test/test.mjs",
"new:unit:test": "NODE_OPTIONS=\"$NODE_OPTIONS --experimental-vm-modules\" jest",
"new:unit:coverage": "pnpm new:unit:test --coverage",
"unit.test": "jasmine JASMINE_CONFIG_PATH=test/unit/jasmine.json",
"unit.test.coverage": "JASMINE_CONFIG_PATH=test/unit/jasmine.json nyc jasmine"
"new:unit:coverage": "pnpm new:unit:test --coverage"
},
"repository": {
"type": "git",
Expand Down
1 change: 1 addition & 0 deletions src/test/test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const __dirname = getCurrentDir(import.meta.url);
*/
generateReport({
saveCollectedJSON: true,
useCDN: true,
jsonDir: "./src/test/data/json/",
reportPath: "./.tmp/browsers/",
reportName: "You can adjust this report name",
Expand Down
5 changes: 4 additions & 1 deletion src/utils/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,7 @@ export const formatToLocalIso = (date: Date): string =>
DateTime.fromJSDate(date).toFormat("yyyy/MM/dd HH:mm:ss");

export const calculatePercentage = (amount: number, total: number): number =>
(amount / total) * 100;
round((amount / total) * 100);

const round = (value: number): number =>
Math.round((value + Number.EPSILON) * 100) / 100;

0 comments on commit 8ebae8c

Please sign in to comment.