@lyxa.ai/types 1.3.121 → 1.3.122

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/README.md CHANGED
@@ -22,7 +22,7 @@ Perfect for sharing types between frontend and backend applications.
22
22
 
23
23
  ## Version
24
24
 
25
- Version: 1.3.121
25
+ Version: 1.3.122
26
26
 
27
27
  ## Dependencies
28
28
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lyxa.ai/types",
3
- "version": "1.3.121",
3
+ "version": "1.3.122",
4
4
  "description": "Lyxa type definitions and validation schemas for both frontend and backend",
5
5
  "author": "elie <42282499+Internalizable@users.noreply.github.com>",
6
6
  "license": "MIT",
@@ -5,14 +5,15 @@ exports.BaseCurrencyRoundTo = 0.01;
5
5
  exports.SecondaryCurrencyRoundTo = 1000;
6
6
  const roundCurrencySync = (amount, roundingFactor) => {
7
7
  if (typeof amount !== 'number' ||
8
- isNaN(amount) ||
8
+ Number.isNaN(amount) ||
9
9
  typeof roundingFactor !== 'number' ||
10
10
  roundingFactor <= 0 ||
11
11
  amount === 0) {
12
12
  return 0;
13
13
  }
14
14
  const decimals = (roundingFactor.toString().split('.')[1] || '').length;
15
- const rounded = Math.round((amount + Number.EPSILON) / roundingFactor) * roundingFactor;
15
+ const safeAmount = Number(amount.toFixed(decimals + 2));
16
+ const rounded = Math.round(safeAmount / roundingFactor) * roundingFactor;
16
17
  return Number(rounded.toFixed(decimals));
17
18
  };
18
19
  exports.roundCurrencySync = roundCurrencySync;
@@ -1 +1 @@
1
- {"version":3,"file":"currency.js","sourceRoot":"/","sources":["utilities/shared/currency.ts"],"names":[],"mappings":";;;AACa,QAAA,mBAAmB,GAAG,IAAI,CAAC;AAC3B,QAAA,wBAAwB,GAAG,IAAI,CAAC;AAGtC,MAAM,iBAAiB,GAAG,CAAC,MAAc,EAAE,cAAsB,EAAU,EAAE;IACnF,IACC,OAAO,MAAM,KAAK,QAAQ;QAC1B,KAAK,CAAC,MAAM,CAAC;QACb,OAAO,cAAc,KAAK,QAAQ;QAClC,cAAc,IAAI,CAAC;QACnB,MAAM,KAAK,CAAC,EACX,CAAC;QACF,OAAO,CAAC,CAAC;IACV,CAAC;IAED,MAAM,QAAQ,GAAG,CAAC,cAAc,CAAC,QAAQ,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC;IACxE,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,GAAG,cAAc,CAAC,GAAG,cAAc,CAAC;IAExF,OAAO,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC;AAC1C,CAAC,CAAC;AAfW,QAAA,iBAAiB,qBAe5B;AAGK,MAAM,iBAAiB,GAAG,CAAC,MAAc,EAAU,EAAE;IAC3D,OAAO,IAAA,yBAAiB,EAAC,MAAM,EAAE,2BAAmB,CAAC,CAAC;AACvD,CAAC,CAAC;AAFW,QAAA,iBAAiB,qBAE5B;AAEK,MAAM,sBAAsB,GAAG,CAAC,MAAc,EAAU,EAAE;IAChE,OAAO,IAAA,yBAAiB,EAAC,MAAM,EAAE,gCAAwB,CAAC,CAAC;AAC5D,CAAC,CAAC;AAFW,QAAA,sBAAsB,0BAEjC","sourcesContent":["// === Currency Rounding Constants ===\nexport const BaseCurrencyRoundTo = 0.01;\nexport const SecondaryCurrencyRoundTo = 1000;\n\n// === Safely rounds a number to the nearest rounding unit ===\nexport const roundCurrencySync = (amount: number, roundingFactor: number): number => {\n\tif (\n\t\ttypeof amount !== 'number' ||\n\t\tisNaN(amount) ||\n\t\ttypeof roundingFactor !== 'number' ||\n\t\troundingFactor <= 0 ||\n\t\tamount === 0\n\t) {\n\t\treturn 0;\n\t}\n\n\tconst decimals = (roundingFactor.toString().split('.')[1] || '').length;\n\tconst rounded = Math.round((amount + Number.EPSILON) / roundingFactor) * roundingFactor;\n\n\treturn Number(rounded.toFixed(decimals));\n};\n\n// === Specific rounding functions for base and secondary currencies ===\nexport const roundBaseCurrency = (amount: number): number => {\n\treturn roundCurrencySync(amount, BaseCurrencyRoundTo);\n};\n\nexport const roundSecondaryCurrency = (amount: number): number => {\n\treturn roundCurrencySync(amount, SecondaryCurrencyRoundTo);\n};\n"]}
1
+ {"version":3,"file":"currency.js","sourceRoot":"/","sources":["utilities/shared/currency.ts"],"names":[],"mappings":";;;AACa,QAAA,mBAAmB,GAAG,IAAI,CAAC;AAC3B,QAAA,wBAAwB,GAAG,IAAI,CAAC;AAGtC,MAAM,iBAAiB,GAAG,CAAC,MAAc,EAAE,cAAsB,EAAU,EAAE;IACnF,IACC,OAAO,MAAM,KAAK,QAAQ;QAC1B,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC;QACpB,OAAO,cAAc,KAAK,QAAQ;QAClC,cAAc,IAAI,CAAC;QACnB,MAAM,KAAK,CAAC,EACX,CAAC;QACF,OAAO,CAAC,CAAC;IACV,CAAC;IAED,MAAM,QAAQ,GAAG,CAAC,cAAc,CAAC,QAAQ,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC;IAExE,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC,CAAC,CAAC;IACxD,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,UAAU,GAAG,cAAc,CAAC,GAAG,cAAc,CAAC;IAEzE,OAAO,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC;AAC1C,CAAC,CAAC;AAjBW,QAAA,iBAAiB,qBAiB5B;AAGK,MAAM,iBAAiB,GAAG,CAAC,MAAc,EAAU,EAAE;IAC3D,OAAO,IAAA,yBAAiB,EAAC,MAAM,EAAE,2BAAmB,CAAC,CAAC;AACvD,CAAC,CAAC;AAFW,QAAA,iBAAiB,qBAE5B;AAEK,MAAM,sBAAsB,GAAG,CAAC,MAAc,EAAU,EAAE;IAChE,OAAO,IAAA,yBAAiB,EAAC,MAAM,EAAE,gCAAwB,CAAC,CAAC;AAC5D,CAAC,CAAC;AAFW,QAAA,sBAAsB,0BAEjC","sourcesContent":["// === Currency Rounding Constants ===\nexport const BaseCurrencyRoundTo = 0.01;\nexport const SecondaryCurrencyRoundTo = 1000;\n\n// === Safely rounds a number to the nearest rounding unit ===\nexport const roundCurrencySync = (amount: number, roundingFactor: number): number => {\n\tif (\n\t\ttypeof amount !== 'number' ||\n\t\tNumber.isNaN(amount) ||\n\t\ttypeof roundingFactor !== 'number' ||\n\t\troundingFactor <= 0 ||\n\t\tamount === 0\n\t) {\n\t\treturn 0;\n\t}\n\n\tconst decimals = (roundingFactor.toString().split('.')[1] || '').length;\n\n\tconst safeAmount = Number(amount.toFixed(decimals + 2));\n\tconst rounded = Math.round(safeAmount / roundingFactor) * roundingFactor;\n\n\treturn Number(rounded.toFixed(decimals));\n};\n\n// === Specific rounding functions for base and secondary currencies ===\nexport const roundBaseCurrency = (amount: number): number => {\n\treturn roundCurrencySync(amount, BaseCurrencyRoundTo);\n};\n\nexport const roundSecondaryCurrency = (amount: number): number => {\n\treturn roundCurrencySync(amount, SecondaryCurrencyRoundTo);\n};\n"]}