Skip to content

Commit 8fc2b96

Browse files
committed
handle 0 values
1 parent a1c26e0 commit 8fc2b96

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

dev-packages/node-overhead-gh-action/lib/Formatter.mjs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
1-
import * as core from '@actions/core';
2-
31
const NODE_OVERHEAD_RESULTS_HEADER = ['Scenario', 'Prev Requests/s', 'New Requests/s', 'Change %'];
42

53
export class Formatter {
64
formatPercentageChange(base = 0, current = 0) {
5+
if (base === 0) {
6+
return 'added';
7+
}
8+
9+
if (current === 0) {
10+
return 'removed';
11+
}
12+
713
const value = ((current - base) / base) * 100;
814
const formatted = (Math.sign(value) * Math.ceil(Math.abs(value) * 100)) / 100;
915

0 commit comments

Comments
 (0)