1 | "use strict";
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", {
|
4 | value: true
|
5 | });
|
6 | exports.formatDecimal = formatDecimal;
|
7 |
|
8 |
|
9 |
|
10 | const NUMBER_REGEX = new RegExp('(\\d+?)(?=(\\d{3})+(?!\\d)|$)', 'g');
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 | function formatDecimal(value) {
|
17 |
|
18 |
|
19 | const isNegative = value[0].startsWith('-');
|
20 | const matched = isNegative ? value.substring(1).match(NUMBER_REGEX) : value.match(NUMBER_REGEX);
|
21 | return matched ? `${isNegative ? '-' : ''}${matched.join(',')}` : value;
|
22 | } |
\ | No newline at end of file |