@augment-vir/common 18.1.0 → 18.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -8,14 +8,21 @@ function addCommasToNumber(input) {
|
|
|
8
8
|
if (typeof input === 'string' && isNaN(Number(input))) {
|
|
9
9
|
return exports.NaNString;
|
|
10
10
|
}
|
|
11
|
-
const
|
|
11
|
+
const numericValue = Number(input);
|
|
12
|
+
const isNegative = numericValue < 0;
|
|
13
|
+
const stringValue = String(Math.abs(numericValue));
|
|
12
14
|
const [digits, decimalValues,] = stringValue.split('.');
|
|
13
15
|
const decimalString = decimalValues ? `.${decimalValues}` : '';
|
|
14
16
|
const separated = (0, regexp_1.safeMatch)(digits.split('').reverse().join(''), /.{1,3}/g)
|
|
15
17
|
.reverse()
|
|
16
18
|
.map((entry) => entry.split('').reverse().join(''));
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
+
const valueWithCommas = separated.join(',');
|
|
20
|
+
const negativeMarker = isNegative ? '-' : '';
|
|
21
|
+
return [
|
|
22
|
+
negativeMarker,
|
|
23
|
+
valueWithCommas,
|
|
24
|
+
decimalString,
|
|
25
|
+
].join('');
|
|
19
26
|
}
|
|
20
27
|
exports.addCommasToNumber = addCommasToNumber;
|
|
21
28
|
function clamp(
|
|
@@ -5,14 +5,21 @@ export function addCommasToNumber(input) {
|
|
|
5
5
|
if (typeof input === 'string' && isNaN(Number(input))) {
|
|
6
6
|
return NaNString;
|
|
7
7
|
}
|
|
8
|
-
const
|
|
8
|
+
const numericValue = Number(input);
|
|
9
|
+
const isNegative = numericValue < 0;
|
|
10
|
+
const stringValue = String(Math.abs(numericValue));
|
|
9
11
|
const [digits, decimalValues,] = stringValue.split('.');
|
|
10
12
|
const decimalString = decimalValues ? `.${decimalValues}` : '';
|
|
11
13
|
const separated = safeMatch(digits.split('').reverse().join(''), /.{1,3}/g)
|
|
12
14
|
.reverse()
|
|
13
15
|
.map((entry) => entry.split('').reverse().join(''));
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
+
const valueWithCommas = separated.join(',');
|
|
17
|
+
const negativeMarker = isNegative ? '-' : '';
|
|
18
|
+
return [
|
|
19
|
+
negativeMarker,
|
|
20
|
+
valueWithCommas,
|
|
21
|
+
decimalString,
|
|
22
|
+
].join('');
|
|
16
23
|
}
|
|
17
24
|
export function clamp(
|
|
18
25
|
/**
|