@xylabs/decimal-precision 2.10.15 → 2.10.16

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.
@@ -0,0 +1,3 @@
1
+ declare const toDecimalPrecision: (value: number, digits: number) => string;
2
+
3
+ export { toDecimalPrecision as default, toDecimalPrecision };
@@ -0,0 +1,3 @@
1
+ declare const toDecimalPrecision: (value: number, digits: number) => string;
2
+
3
+ export { toDecimalPrecision as default, toDecimalPrecision };
package/dist/index.js ADDED
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/index.ts
21
+ var src_exports = {};
22
+ __export(src_exports, {
23
+ default: () => src_default,
24
+ toDecimalPrecision: () => toDecimalPrecision
25
+ });
26
+ module.exports = __toCommonJS(src_exports);
27
+ var toDecimalPrecision = (value, digits) => {
28
+ let fixed = 0;
29
+ const result = parseFloat(value.toPrecision(digits));
30
+ while (parseFloat(result.toFixed(fixed)) !== result && fixed < 20) {
31
+ fixed++;
32
+ }
33
+ return result.toFixed(fixed);
34
+ };
35
+ var src_default = toDecimalPrecision;
36
+ // Annotate the CommonJS export names for ESM import in node:
37
+ 0 && (module.exports = {
38
+ toDecimalPrecision
39
+ });
40
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["export const toDecimalPrecision = (value: number, digits: number) => {\n let fixed = 0\n const result = parseFloat(value.toPrecision(digits))\n while (parseFloat(result.toFixed(fixed)) !== result && fixed < 20) {\n fixed++\n }\n return result.toFixed(fixed)\n}\n\n// eslint-disable-next-line import/no-default-export\nexport default toDecimalPrecision\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,IAAM,qBAAqB,CAAC,OAAe,WAAmB;AACnE,MAAI,QAAQ;AACZ,QAAM,SAAS,WAAW,MAAM,YAAY,MAAM,CAAC;AACnD,SAAO,WAAW,OAAO,QAAQ,KAAK,CAAC,MAAM,UAAU,QAAQ,IAAI;AACjE;AAAA,EACF;AACA,SAAO,OAAO,QAAQ,KAAK;AAC7B;AAGA,IAAO,cAAQ;","names":[]}
package/dist/index.mjs ADDED
@@ -0,0 +1,15 @@
1
+ // src/index.ts
2
+ var toDecimalPrecision = (value, digits) => {
3
+ let fixed = 0;
4
+ const result = parseFloat(value.toPrecision(digits));
5
+ while (parseFloat(result.toFixed(fixed)) !== result && fixed < 20) {
6
+ fixed++;
7
+ }
8
+ return result.toFixed(fixed);
9
+ };
10
+ var src_default = toDecimalPrecision;
11
+ export {
12
+ src_default as default,
13
+ toDecimalPrecision
14
+ };
15
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["export const toDecimalPrecision = (value: number, digits: number) => {\n let fixed = 0\n const result = parseFloat(value.toPrecision(digits))\n while (parseFloat(result.toFixed(fixed)) !== result && fixed < 20) {\n fixed++\n }\n return result.toFixed(fixed)\n}\n\n// eslint-disable-next-line import/no-default-export\nexport default toDecimalPrecision\n"],"mappings":";AAAO,IAAM,qBAAqB,CAAC,OAAe,WAAmB;AACnE,MAAI,QAAQ;AACZ,QAAM,SAAS,WAAW,MAAM,YAAY,MAAM,CAAC;AACnD,SAAO,WAAW,OAAO,QAAQ,KAAK,CAAC,MAAM,UAAU,QAAQ,IAAI;AACjE;AAAA,EACF;AACA,SAAO,OAAO,QAAQ,KAAK;AAC7B;AAGA,IAAO,cAAQ;","names":[]}
package/package.json CHANGED
@@ -52,8 +52,8 @@
52
52
  "esm"
53
53
  ],
54
54
  "devDependencies": {
55
- "@xylabs/ts-scripts-yarn3": "^2.19.9",
56
- "@xylabs/tsconfig": "^2.19.9",
55
+ "@xylabs/ts-scripts-yarn3": "^2.19.11",
56
+ "@xylabs/tsconfig": "^2.19.11",
57
57
  "publint": "^0.2.2",
58
58
  "tsup": "^7.2.0"
59
59
  },
@@ -65,5 +65,5 @@
65
65
  "url": "https://github.com/xylabs/sdk-js.git"
66
66
  },
67
67
  "sideEffects": false,
68
- "version": "2.10.15"
68
+ "version": "2.10.16"
69
69
  }