@react-stately/utils 3.10.7 → 3.10.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/number.main.js +8 -2
- package/dist/number.main.js.map +1 -1
- package/dist/number.mjs +8 -2
- package/dist/number.module.js +8 -2
- package/dist/number.module.js.map +1 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/number.ts +11 -2
package/dist/number.main.js
CHANGED
|
@@ -24,9 +24,15 @@ $parcel$export(module.exports, "toFixedNumber", () => $ac8e4d4816275668$export$b
|
|
|
24
24
|
}
|
|
25
25
|
function $ac8e4d4816275668$export$e1a7b8e69ef6c52f(value, step) {
|
|
26
26
|
let roundedValue = value;
|
|
27
|
+
let precision = 0;
|
|
27
28
|
let stepString = step.toString();
|
|
28
|
-
|
|
29
|
-
let
|
|
29
|
+
// Handle negative exponents in exponential notation (e.g., "1e-7" → precision 8)
|
|
30
|
+
let eIndex = stepString.toLowerCase().indexOf('e-');
|
|
31
|
+
if (eIndex > 0) precision = Math.abs(Math.floor(Math.log10(Math.abs(step)))) + eIndex;
|
|
32
|
+
else {
|
|
33
|
+
let pointIndex = stepString.indexOf('.');
|
|
34
|
+
if (pointIndex >= 0) precision = stepString.length - pointIndex;
|
|
35
|
+
}
|
|
30
36
|
if (precision > 0) {
|
|
31
37
|
let pow = Math.pow(10, precision);
|
|
32
38
|
roundedValue = Math.round(roundedValue * pow) / pow;
|
package/dist/number.main.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;AAAA;;;;;;;;;;CAUC,GAED;;CAEC,GACM,SAAS,0CAAM,KAAa,EAAE,MAAc,CAAC,QAAQ,EAAE,MAAc,QAAQ;IAClF,IAAI,WAAW,KAAK,GAAG,CAAC,KAAK,GAAG,CAAC,OAAO,MAAM;IAC9C,OAAO;AACT;AAEO,SAAS,0CAAqB,KAAa,EAAE,IAAY;IAC9D,IAAI,eAAe;IACnB,IAAI,aAAa,KAAK,QAAQ;IAC9B,IAAI,
|
|
1
|
+
{"mappings":";;;;;;;;AAAA;;;;;;;;;;CAUC,GAED;;CAEC,GACM,SAAS,0CAAM,KAAa,EAAE,MAAc,CAAC,QAAQ,EAAE,MAAc,QAAQ;IAClF,IAAI,WAAW,KAAK,GAAG,CAAC,KAAK,GAAG,CAAC,OAAO,MAAM;IAC9C,OAAO;AACT;AAEO,SAAS,0CAAqB,KAAa,EAAE,IAAY;IAC9D,IAAI,eAAe;IACnB,IAAI,YAAY;IAChB,IAAI,aAAa,KAAK,QAAQ;IAC9B,iFAAiF;IACjF,IAAI,SAAS,WAAW,WAAW,GAAG,OAAO,CAAC;IAC9C,IAAI,SAAS,GACX,YAAY,KAAK,GAAG,CAAC,KAAK,KAAK,CAAC,KAAK,KAAK,CAAC,KAAK,GAAG,CAAC,WAAW;SAC1D;QACL,IAAI,aAAa,WAAW,OAAO,CAAC;QACpC,IAAI,cAAc,GAChB,YAAY,WAAW,MAAM,GAAG;IAEpC;IACA,IAAI,YAAY,GAAG;QACjB,IAAI,MAAM,KAAK,GAAG,CAAC,IAAI;QACvB,eAAe,KAAK,KAAK,CAAC,eAAe,OAAO;IAClD;IACA,OAAO;AACT;AAEO,SAAS,0CAAgB,KAAa,EAAE,GAAuB,EAAE,GAAuB,EAAE,IAAY;IAC3G,MAAM,OAAO;IACb,MAAM,OAAO;IACb,IAAI,YAAa,AAAC,CAAA,QAAS,CAAA,MAAM,OAAO,IAAI,GAAE,CAAC,IAAK;IACpD,IAAI,eAAe,0CAAqB,KAAK,GAAG,CAAC,aAAa,KAAK,OAC/D,QAAQ,KAAK,IAAI,CAAC,aAAc,CAAA,OAAO,KAAK,GAAG,CAAC,UAAS,IACzD,QAAQ,WAAW;IAEvB,IAAI,CAAC,MAAM,MAAM;QACf,IAAI,eAAe,KACjB,eAAe;aACV,IAAI,CAAC,MAAM,QAAQ,eAAe,KACvC,eAAe,MAAM,KAAK,KAAK,CAAC,0CAAqB,AAAC,CAAA,MAAM,GAAE,IAAK,MAAM,SAAS;IAEtF,OAAO,IAAI,CAAC,MAAM,QAAQ,eAAe,KACvC,eAAe,KAAK,KAAK,CAAC,0CAAqB,MAAM,MAAM,SAAS;IAGtE,gEAAgE;IAChE,eAAe,0CAAqB,cAAc;IAElD,OAAO;AACT;AAGO,SAAS,yCAAc,KAAa,EAAE,MAAc,EAAE,OAAe,EAAE;IAC5E,MAAM,MAAM,KAAK,GAAG,CAAC,MAAM;IAE3B,OAAO,KAAK,KAAK,CAAC,QAAQ,OAAO;AACnC","sources":["packages/@react-stately/utils/src/number.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\n/**\n * Takes a value and forces it to the closest min/max if it's outside. Also forces it to the closest valid step.\n */\nexport function clamp(value: number, min: number = -Infinity, max: number = Infinity): number {\n let newValue = Math.min(Math.max(value, min), max);\n return newValue;\n}\n\nexport function roundToStepPrecision(value: number, step: number): number {\n let roundedValue = value;\n let precision = 0;\n let stepString = step.toString();\n // Handle negative exponents in exponential notation (e.g., \"1e-7\" → precision 8)\n let eIndex = stepString.toLowerCase().indexOf('e-');\n if (eIndex > 0) {\n precision = Math.abs(Math.floor(Math.log10(Math.abs(step)))) + eIndex;\n } else {\n let pointIndex = stepString.indexOf('.');\n if (pointIndex >= 0) {\n precision = stepString.length - pointIndex;\n }\n }\n if (precision > 0) {\n let pow = Math.pow(10, precision);\n roundedValue = Math.round(roundedValue * pow) / pow;\n }\n return roundedValue;\n}\n\nexport function snapValueToStep(value: number, min: number | undefined, max: number | undefined, step: number): number {\n min = Number(min);\n max = Number(max);\n let remainder = ((value - (isNaN(min) ? 0 : min)) % step);\n let snappedValue = roundToStepPrecision(Math.abs(remainder) * 2 >= step\n ? value + Math.sign(remainder) * (step - Math.abs(remainder))\n : value - remainder, step);\n\n if (!isNaN(min)) {\n if (snappedValue < min) {\n snappedValue = min;\n } else if (!isNaN(max) && snappedValue > max) {\n snappedValue = min + Math.floor(roundToStepPrecision((max - min) / step, step)) * step;\n }\n } else if (!isNaN(max) && snappedValue > max) {\n snappedValue = Math.floor(roundToStepPrecision(max / step, step)) * step;\n }\n\n // correct floating point behavior by rounding to step precision\n snappedValue = roundToStepPrecision(snappedValue, step);\n\n return snappedValue;\n}\n\n/* Takes a value and rounds off to the number of digits. */\nexport function toFixedNumber(value: number, digits: number, base: number = 10): number {\n const pow = Math.pow(base, digits);\n\n return Math.round(value * pow) / pow;\n}\n"],"names":[],"version":3,"file":"number.main.js.map"}
|
package/dist/number.mjs
CHANGED
|
@@ -16,9 +16,15 @@
|
|
|
16
16
|
}
|
|
17
17
|
function $9446cca9a3875146$export$e1a7b8e69ef6c52f(value, step) {
|
|
18
18
|
let roundedValue = value;
|
|
19
|
+
let precision = 0;
|
|
19
20
|
let stepString = step.toString();
|
|
20
|
-
|
|
21
|
-
let
|
|
21
|
+
// Handle negative exponents in exponential notation (e.g., "1e-7" → precision 8)
|
|
22
|
+
let eIndex = stepString.toLowerCase().indexOf('e-');
|
|
23
|
+
if (eIndex > 0) precision = Math.abs(Math.floor(Math.log10(Math.abs(step)))) + eIndex;
|
|
24
|
+
else {
|
|
25
|
+
let pointIndex = stepString.indexOf('.');
|
|
26
|
+
if (pointIndex >= 0) precision = stepString.length - pointIndex;
|
|
27
|
+
}
|
|
22
28
|
if (precision > 0) {
|
|
23
29
|
let pow = Math.pow(10, precision);
|
|
24
30
|
roundedValue = Math.round(roundedValue * pow) / pow;
|
package/dist/number.module.js
CHANGED
|
@@ -16,9 +16,15 @@
|
|
|
16
16
|
}
|
|
17
17
|
function $9446cca9a3875146$export$e1a7b8e69ef6c52f(value, step) {
|
|
18
18
|
let roundedValue = value;
|
|
19
|
+
let precision = 0;
|
|
19
20
|
let stepString = step.toString();
|
|
20
|
-
|
|
21
|
-
let
|
|
21
|
+
// Handle negative exponents in exponential notation (e.g., "1e-7" → precision 8)
|
|
22
|
+
let eIndex = stepString.toLowerCase().indexOf('e-');
|
|
23
|
+
if (eIndex > 0) precision = Math.abs(Math.floor(Math.log10(Math.abs(step)))) + eIndex;
|
|
24
|
+
else {
|
|
25
|
+
let pointIndex = stepString.indexOf('.');
|
|
26
|
+
if (pointIndex >= 0) precision = stepString.length - pointIndex;
|
|
27
|
+
}
|
|
22
28
|
if (precision > 0) {
|
|
23
29
|
let pow = Math.pow(10, precision);
|
|
24
30
|
roundedValue = Math.round(roundedValue * pow) / pow;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"AAAA;;;;;;;;;;CAUC,GAED;;CAEC,GACM,SAAS,0CAAM,KAAa,EAAE,MAAc,CAAC,QAAQ,EAAE,MAAc,QAAQ;IAClF,IAAI,WAAW,KAAK,GAAG,CAAC,KAAK,GAAG,CAAC,OAAO,MAAM;IAC9C,OAAO;AACT;AAEO,SAAS,0CAAqB,KAAa,EAAE,IAAY;IAC9D,IAAI,eAAe;IACnB,IAAI,aAAa,KAAK,QAAQ;IAC9B,IAAI,
|
|
1
|
+
{"mappings":"AAAA;;;;;;;;;;CAUC,GAED;;CAEC,GACM,SAAS,0CAAM,KAAa,EAAE,MAAc,CAAC,QAAQ,EAAE,MAAc,QAAQ;IAClF,IAAI,WAAW,KAAK,GAAG,CAAC,KAAK,GAAG,CAAC,OAAO,MAAM;IAC9C,OAAO;AACT;AAEO,SAAS,0CAAqB,KAAa,EAAE,IAAY;IAC9D,IAAI,eAAe;IACnB,IAAI,YAAY;IAChB,IAAI,aAAa,KAAK,QAAQ;IAC9B,iFAAiF;IACjF,IAAI,SAAS,WAAW,WAAW,GAAG,OAAO,CAAC;IAC9C,IAAI,SAAS,GACX,YAAY,KAAK,GAAG,CAAC,KAAK,KAAK,CAAC,KAAK,KAAK,CAAC,KAAK,GAAG,CAAC,WAAW;SAC1D;QACL,IAAI,aAAa,WAAW,OAAO,CAAC;QACpC,IAAI,cAAc,GAChB,YAAY,WAAW,MAAM,GAAG;IAEpC;IACA,IAAI,YAAY,GAAG;QACjB,IAAI,MAAM,KAAK,GAAG,CAAC,IAAI;QACvB,eAAe,KAAK,KAAK,CAAC,eAAe,OAAO;IAClD;IACA,OAAO;AACT;AAEO,SAAS,0CAAgB,KAAa,EAAE,GAAuB,EAAE,GAAuB,EAAE,IAAY;IAC3G,MAAM,OAAO;IACb,MAAM,OAAO;IACb,IAAI,YAAa,AAAC,CAAA,QAAS,CAAA,MAAM,OAAO,IAAI,GAAE,CAAC,IAAK;IACpD,IAAI,eAAe,0CAAqB,KAAK,GAAG,CAAC,aAAa,KAAK,OAC/D,QAAQ,KAAK,IAAI,CAAC,aAAc,CAAA,OAAO,KAAK,GAAG,CAAC,UAAS,IACzD,QAAQ,WAAW;IAEvB,IAAI,CAAC,MAAM,MAAM;QACf,IAAI,eAAe,KACjB,eAAe;aACV,IAAI,CAAC,MAAM,QAAQ,eAAe,KACvC,eAAe,MAAM,KAAK,KAAK,CAAC,0CAAqB,AAAC,CAAA,MAAM,GAAE,IAAK,MAAM,SAAS;IAEtF,OAAO,IAAI,CAAC,MAAM,QAAQ,eAAe,KACvC,eAAe,KAAK,KAAK,CAAC,0CAAqB,MAAM,MAAM,SAAS;IAGtE,gEAAgE;IAChE,eAAe,0CAAqB,cAAc;IAElD,OAAO;AACT;AAGO,SAAS,yCAAc,KAAa,EAAE,MAAc,EAAE,OAAe,EAAE;IAC5E,MAAM,MAAM,KAAK,GAAG,CAAC,MAAM;IAE3B,OAAO,KAAK,KAAK,CAAC,QAAQ,OAAO;AACnC","sources":["packages/@react-stately/utils/src/number.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\n/**\n * Takes a value and forces it to the closest min/max if it's outside. Also forces it to the closest valid step.\n */\nexport function clamp(value: number, min: number = -Infinity, max: number = Infinity): number {\n let newValue = Math.min(Math.max(value, min), max);\n return newValue;\n}\n\nexport function roundToStepPrecision(value: number, step: number): number {\n let roundedValue = value;\n let precision = 0;\n let stepString = step.toString();\n // Handle negative exponents in exponential notation (e.g., \"1e-7\" → precision 8)\n let eIndex = stepString.toLowerCase().indexOf('e-');\n if (eIndex > 0) {\n precision = Math.abs(Math.floor(Math.log10(Math.abs(step)))) + eIndex;\n } else {\n let pointIndex = stepString.indexOf('.');\n if (pointIndex >= 0) {\n precision = stepString.length - pointIndex;\n }\n }\n if (precision > 0) {\n let pow = Math.pow(10, precision);\n roundedValue = Math.round(roundedValue * pow) / pow;\n }\n return roundedValue;\n}\n\nexport function snapValueToStep(value: number, min: number | undefined, max: number | undefined, step: number): number {\n min = Number(min);\n max = Number(max);\n let remainder = ((value - (isNaN(min) ? 0 : min)) % step);\n let snappedValue = roundToStepPrecision(Math.abs(remainder) * 2 >= step\n ? value + Math.sign(remainder) * (step - Math.abs(remainder))\n : value - remainder, step);\n\n if (!isNaN(min)) {\n if (snappedValue < min) {\n snappedValue = min;\n } else if (!isNaN(max) && snappedValue > max) {\n snappedValue = min + Math.floor(roundToStepPrecision((max - min) / step, step)) * step;\n }\n } else if (!isNaN(max) && snappedValue > max) {\n snappedValue = Math.floor(roundToStepPrecision(max / step, step)) * step;\n }\n\n // correct floating point behavior by rounding to step precision\n snappedValue = roundToStepPrecision(snappedValue, step);\n\n return snappedValue;\n}\n\n/* Takes a value and rounds off to the number of digits. */\nexport function toFixedNumber(value: number, digits: number, base: number = 10): number {\n const pow = Math.pow(base, digits);\n\n return Math.round(value * pow) / pow;\n}\n"],"names":[],"version":3,"file":"number.module.js.map"}
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"AAcA,mCAAmC,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC,EAAE,SAAS,CAAC,EAAE,YAAY,EAAE,OAAO,CAAC,CAAC,EAAE,SAAS,CAAC,GAAG,SAAS,EAAE,QAAQ,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,GAAG,CAAC,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,CAAC,CAAC;AAChN,mCAAmC,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC,EAAE,SAAS,CAAC,GAAG,SAAS,EAAE,YAAY,EAAE,OAAO,CAAC,CAAC,EAAE,SAAS,CAAC,EAAE,QAAQ,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,GAAG,CAAC,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,CAAC,CAAC;ACHhN;;GAEG;AACH,sBAAsB,KAAK,EAAE,MAAM,EAAE,GAAG,GAAE,MAAkB,EAAE,GAAG,GAAE,MAAiB,GAAG,MAAM,CAG5F;
|
|
1
|
+
{"mappings":"AAcA,mCAAmC,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC,EAAE,SAAS,CAAC,EAAE,YAAY,EAAE,OAAO,CAAC,CAAC,EAAE,SAAS,CAAC,GAAG,SAAS,EAAE,QAAQ,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,GAAG,CAAC,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,CAAC,CAAC;AAChN,mCAAmC,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC,EAAE,SAAS,CAAC,GAAG,SAAS,EAAE,YAAY,EAAE,OAAO,CAAC,CAAC,EAAE,SAAS,CAAC,EAAE,QAAQ,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,GAAG,CAAC,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,CAAC,CAAC;ACHhN;;GAEG;AACH,sBAAsB,KAAK,EAAE,MAAM,EAAE,GAAG,GAAE,MAAkB,EAAE,GAAG,GAAE,MAAiB,GAAG,MAAM,CAG5F;AAuBD,gCAAgC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,SAAS,EAAE,GAAG,EAAE,MAAM,GAAG,SAAS,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAsBrH;AAGD,8BAA8B,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,GAAE,MAAW,GAAG,MAAM,CAItF","sources":["packages/@react-stately/utils/src/packages/@react-stately/utils/src/useControlledState.ts","packages/@react-stately/utils/src/packages/@react-stately/utils/src/number.ts","packages/@react-stately/utils/src/packages/@react-stately/utils/src/index.ts","packages/@react-stately/utils/src/index.ts"],"sourcesContent":[null,null,null,"/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\nexport {useControlledState} from './useControlledState';\nexport {clamp, snapValueToStep, toFixedNumber} from './number';\n"],"names":[],"version":3,"file":"types.d.ts.map"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-stately/utils",
|
|
3
|
-
"version": "3.10.
|
|
3
|
+
"version": "3.10.8",
|
|
4
4
|
"description": "Spectrum UI components in React",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "dist/main.js",
|
|
@@ -34,5 +34,5 @@
|
|
|
34
34
|
"publishConfig": {
|
|
35
35
|
"access": "public"
|
|
36
36
|
},
|
|
37
|
-
"gitHead": "
|
|
37
|
+
"gitHead": "8b9348ff255e018b2dd9b27e2a45507cadfa1d35"
|
|
38
38
|
}
|
package/src/number.ts
CHANGED
|
@@ -20,9 +20,18 @@ export function clamp(value: number, min: number = -Infinity, max: number = Infi
|
|
|
20
20
|
|
|
21
21
|
export function roundToStepPrecision(value: number, step: number): number {
|
|
22
22
|
let roundedValue = value;
|
|
23
|
+
let precision = 0;
|
|
23
24
|
let stepString = step.toString();
|
|
24
|
-
|
|
25
|
-
let
|
|
25
|
+
// Handle negative exponents in exponential notation (e.g., "1e-7" → precision 8)
|
|
26
|
+
let eIndex = stepString.toLowerCase().indexOf('e-');
|
|
27
|
+
if (eIndex > 0) {
|
|
28
|
+
precision = Math.abs(Math.floor(Math.log10(Math.abs(step)))) + eIndex;
|
|
29
|
+
} else {
|
|
30
|
+
let pointIndex = stepString.indexOf('.');
|
|
31
|
+
if (pointIndex >= 0) {
|
|
32
|
+
precision = stepString.length - pointIndex;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
26
35
|
if (precision > 0) {
|
|
27
36
|
let pow = Math.pow(10, precision);
|
|
28
37
|
roundedValue = Math.round(roundedValue * pow) / pow;
|