Skip to content

Commit e5e1347

Browse files
committed
fix: infinite loop
1 parent d9667b3 commit e5e1347

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/helpers.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,13 @@ export const formatThousands = (val: string, options: IOptions): string => {
1919
// i must be greater than zero because number cannot start with comma
2020
let i = startIndex;
2121
let j = 1;
22-
for (i > endIndex; i--, j++;) {
22+
while(i > endIndex) {
2323
// Every 3 characters, add a comma
2424
if (j % 3 === 0) {
2525
val = editString(val, options.thousands, i);
2626
}
27+
i--;
28+
j++;
2729
}
2830

2931
return val;

0 commit comments

Comments
 (0)