@wikicasa-dev/utilities 1.1.7 → 1.1.8
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/NumberUtils.cjs +1 -1
- package/dist/NumberUtils.js +6 -5
- package/package.json +1 -1
package/dist/NumberUtils.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=(r,t="it-IT")=>{const e=Intl.NumberFormat(t).format(1111).replace(/\p{Number}/gu,""),a=Intl.NumberFormat(t).format(1.1).replace(/\p{Number}/gu,""),o=parseFloat(`${r}`.replace(new RegExp("\\"+e,"g"),"").replace(new RegExp("\\"+a),"."));return isNaN(o)?"":o},i=r=>u(r,navigator.language),c=(r,t,e="it-IT")=>{if(r==null)return;if(r=parseFloat(`${r}`),isNaN(r))return"";const a={style:"currency",currency:"EUR"};let n={...{maximumFractionDigits:0}};return t?.currency&&(n={...n,...a}),new Intl.NumberFormat(e,{...n}).format(r)},
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=(r,t="it-IT")=>{const e=Intl.NumberFormat(t).format(1111).replace(/\p{Number}/gu,""),a=Intl.NumberFormat(t).format(1.1).replace(/\p{Number}/gu,""),o=parseFloat(`${r}`.replace(new RegExp("\\"+e,"g"),"").replace(new RegExp("\\"+a),"."));return isNaN(o)?"":o},i=r=>u(r,navigator.language),c=(r,t,e="it-IT")=>{if(r==null)return;if(r=parseFloat(`${r}`),isNaN(r))return"";const a={style:"currency",currency:"EUR"};let n={...{maximumFractionDigits:0}};return t?.currency&&(n={...n,...a}),new Intl.NumberFormat(e,{...n}).format(r)},s=(r,t)=>c(r,t,navigator.language);function l(r,t=!1){return r==null?"":m(t?Math.round(r):Math.floor(r),0)}function m(r,t){return!r&&r!==0?"":r.toLocaleString("it-IT",{minimumFractionDigits:t,maximumFractionDigits:t,useGrouping:"always"})}function f(r,t=2){return m(r,t)}const p={formatFn:r=>c(r)??"",unFormatFn:r=>u(r)};exports.formatFloat=f;exports.formatInteger=l;exports.formatLocaleNumber=c;exports.formatLocaleNumberAuto=s;exports.formatNumber=m;exports.formatterNumberObj=p;exports.parseLocaleNumber=u;exports.parseLocaleNumberAuto=i;
|
package/dist/NumberUtils.js
CHANGED
|
@@ -3,7 +3,7 @@ const u = (r, t = "it-IT") => {
|
|
|
3
3
|
`${r}`.replace(new RegExp("\\" + e, "g"), "").replace(new RegExp("\\" + n), ".")
|
|
4
4
|
);
|
|
5
5
|
return isNaN(a) ? "" : a;
|
|
6
|
-
},
|
|
6
|
+
}, s = (r) => u(r, navigator.language), i = (r, t, e = "it-IT") => {
|
|
7
7
|
if (r == null) return;
|
|
8
8
|
if (r = parseFloat(`${r}`), isNaN(r)) return "";
|
|
9
9
|
const n = {
|
|
@@ -16,7 +16,7 @@ const u = (r, t = "it-IT") => {
|
|
|
16
16
|
return t?.currency && (o = { ...o, ...n }), new Intl.NumberFormat(e, {
|
|
17
17
|
...o
|
|
18
18
|
}).format(r);
|
|
19
|
-
},
|
|
19
|
+
}, m = (r, t) => i(r, t, navigator.language);
|
|
20
20
|
function f(r, t = !1) {
|
|
21
21
|
return r == null ? "" : c(t ? Math.round(r) : Math.floor(r), 0);
|
|
22
22
|
}
|
|
@@ -26,7 +26,8 @@ function c(r, t) {
|
|
|
26
26
|
// usare una stringa tipo 'en-US' per sovrascrivere la lingua del browser
|
|
27
27
|
{
|
|
28
28
|
minimumFractionDigits: t,
|
|
29
|
-
maximumFractionDigits: t
|
|
29
|
+
maximumFractionDigits: t,
|
|
30
|
+
useGrouping: "always"
|
|
30
31
|
}
|
|
31
32
|
);
|
|
32
33
|
}
|
|
@@ -41,9 +42,9 @@ export {
|
|
|
41
42
|
l as formatFloat,
|
|
42
43
|
f as formatInteger,
|
|
43
44
|
i as formatLocaleNumber,
|
|
44
|
-
|
|
45
|
+
m as formatLocaleNumberAuto,
|
|
45
46
|
c as formatNumber,
|
|
46
47
|
p as formatterNumberObj,
|
|
47
48
|
u as parseLocaleNumber,
|
|
48
|
-
|
|
49
|
+
s as parseLocaleNumberAuto
|
|
49
50
|
};
|