@neovici/cosmoz-utils 5.10.2 → 5.11.0
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.
- package/dist/number.d.ts +2 -0
- package/dist/number.js +14 -0
- package/package.json +2 -1
package/dist/number.d.ts
ADDED
package/dist/number.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export const parse = (value) => {
|
|
2
|
+
if (!value || value === Infinity)
|
|
3
|
+
return;
|
|
4
|
+
if (typeof value === 'number')
|
|
5
|
+
return value;
|
|
6
|
+
const num = parseFloat(value
|
|
7
|
+
.replace(/[\s]/gu, '')
|
|
8
|
+
.replace(/[,.]/gu, '.')
|
|
9
|
+
.replace(/[.](?=.*[.])/gu, ''));
|
|
10
|
+
if (isNaN(num))
|
|
11
|
+
return;
|
|
12
|
+
return num;
|
|
13
|
+
};
|
|
14
|
+
export const round = (num, precision = 2) => parse(num.toFixed(precision));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@neovici/cosmoz-utils",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.11.0",
|
|
4
4
|
"description": "Date, money and template management functions commonly needed in Cosmoz views.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"polymer",
|
|
@@ -55,6 +55,7 @@
|
|
|
55
55
|
"./array": "./dist/array.js",
|
|
56
56
|
"./date": "./dist/date.js",
|
|
57
57
|
"./function": "./dist/function.js",
|
|
58
|
+
"./number": "./dist/number.js",
|
|
58
59
|
"./location": "./dist/location.js",
|
|
59
60
|
"./money": "./dist/money.js",
|
|
60
61
|
"./promise": "./dist/promise.js",
|