@n8n/utils 1.3.0 → 1.5.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.
@@ -0,0 +1,14 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/number/smartDecimal.ts
2
+ var smartDecimal = (value, decimals = 2) => {
3
+ if (Number.isInteger(value)) {
4
+ return value;
5
+ }
6
+ if (value.toString().split(".")[1].length <= decimals) {
7
+ return value;
8
+ }
9
+ return Number(value.toFixed(decimals));
10
+ };
11
+
12
+
13
+ exports.smartDecimal = smartDecimal;
14
+ //# sourceMappingURL=smartDecimal.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/home/runner/work/n8n/n8n/packages/@n8n/utils/dist/number/smartDecimal.cjs","../../src/number/smartDecimal.ts"],"names":[],"mappings":"AAAA;ACAO,IAAM,aAAA,EAAe,CAAC,KAAA,EAAe,SAAA,EAAW,CAAA,EAAA,GAAc;AAEpE,EAAA,GAAA,CAAI,MAAA,CAAO,SAAA,CAAU,KAAK,CAAA,EAAG;AAC5B,IAAA,OAAO,KAAA;AAAA,EACR;AAGA,EAAA,GAAA,CAAI,KAAA,CAAM,QAAA,CAAS,CAAA,CAAE,KAAA,CAAM,GAAG,CAAA,CAAE,CAAC,CAAA,CAAE,OAAA,GAAU,QAAA,EAAU;AACtD,IAAA,OAAO,KAAA;AAAA,EACR;AAEA,EAAA,OAAO,MAAA,CAAO,KAAA,CAAM,OAAA,CAAQ,QAAQ,CAAC,CAAA;AACtC,CAAA;ADFA;AACE;AACF,oCAAC","file":"/home/runner/work/n8n/n8n/packages/@n8n/utils/dist/number/smartDecimal.cjs","sourcesContent":[null,"export const smartDecimal = (value: number, decimals = 2): number => {\n\t// Check if integer\n\tif (Number.isInteger(value)) {\n\t\treturn value;\n\t}\n\n\t// Check if it has only one decimal place\n\tif (value.toString().split('.')[1].length <= decimals) {\n\t\treturn value;\n\t}\n\n\treturn Number(value.toFixed(decimals));\n};\n"]}
@@ -0,0 +1,3 @@
1
+ declare const smartDecimal: (value: number, decimals?: number) => number;
2
+
3
+ export { smartDecimal };
@@ -0,0 +1,3 @@
1
+ declare const smartDecimal: (value: number, decimals?: number) => number;
2
+
3
+ export { smartDecimal };
@@ -0,0 +1,14 @@
1
+ // src/number/smartDecimal.ts
2
+ var smartDecimal = (value, decimals = 2) => {
3
+ if (Number.isInteger(value)) {
4
+ return value;
5
+ }
6
+ if (value.toString().split(".")[1].length <= decimals) {
7
+ return value;
8
+ }
9
+ return Number(value.toFixed(decimals));
10
+ };
11
+ export {
12
+ smartDecimal
13
+ };
14
+ //# sourceMappingURL=smartDecimal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/number/smartDecimal.ts"],"sourcesContent":["export const smartDecimal = (value: number, decimals = 2): number => {\n\t// Check if integer\n\tif (Number.isInteger(value)) {\n\t\treturn value;\n\t}\n\n\t// Check if it has only one decimal place\n\tif (value.toString().split('.')[1].length <= decimals) {\n\t\treturn value;\n\t}\n\n\treturn Number(value.toFixed(decimals));\n};\n"],"mappings":";AAAO,IAAM,eAAe,CAAC,OAAe,WAAW,MAAc;AAEpE,MAAI,OAAO,UAAU,KAAK,GAAG;AAC5B,WAAO;AAAA,EACR;AAGA,MAAI,MAAM,SAAS,EAAE,MAAM,GAAG,EAAE,CAAC,EAAE,UAAU,UAAU;AACtD,WAAO;AAAA,EACR;AAEA,SAAO,OAAO,MAAM,QAAQ,QAAQ,CAAC;AACtC;","names":[]}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@n8n/utils",
3
3
  "type": "module",
4
- "version": "1.3.0",
4
+ "version": "1.5.0",
5
5
  "files": [
6
6
  "dist",
7
7
  "LICENSE.md",
@@ -16,15 +16,14 @@
16
16
  },
17
17
  "devDependencies": {
18
18
  "@testing-library/jest-dom": "^6.6.3",
19
- "@testing-library/user-event": "^14.6.0",
20
- "tsup": "^8.3.6",
21
- "typescript": "^5.6.2",
22
- "vite": "^6.0.2",
23
- "vite-plugin-dts": "^4.3.0",
24
- "vitest": "^3.0.5",
25
- "@n8n/vitest-config": "1.2.0",
19
+ "@testing-library/user-event": "^14.6.1",
20
+ "tsup": "^8.4.0",
21
+ "typescript": "^5.8.2",
22
+ "vite": "^6.2.0",
23
+ "vitest": "^3.0.7",
24
+ "@n8n/typescript-config": "1.2.0",
26
25
  "@n8n/eslint-config": "0.0.1",
27
- "@n8n/typescript-config": "1.2.0"
26
+ "@n8n/vitest-config": "1.2.0"
28
27
  },
29
28
  "license": "SEE LICENSE IN LICENSE.md",
30
29
  "homepage": "https://n8n.io",