@amboras-dev/money 0.2.0 → 0.4.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.
Files changed (78) hide show
  1. package/README.md +22 -11
  2. package/dist/ai.cjs +12 -13
  3. package/dist/ai.d.cts +5 -9
  4. package/dist/ai.d.ts +5 -9
  5. package/dist/ai.js +12 -13
  6. package/dist/{allocate-CZRg4TOP.cjs → allocate-AusholrC.cjs} +3 -4
  7. package/dist/{allocate-X7_jAtOj.js → allocate-BBRfdaSC.js} +3 -4
  8. package/dist/{amount-BV0O-aN8.cjs → amount-Bzxw9aD4.cjs} +32 -14
  9. package/dist/{amount-BoYBMgK9.js → amount-off8IMBJ.js} +32 -14
  10. package/dist/{arithmetic-BhNwisjb.js → arithmetic-C97-YafD.js} +4 -5
  11. package/dist/{arithmetic-DjT4Kzgt.cjs → arithmetic-D8A6IeZ0.cjs} +4 -5
  12. package/dist/billing.cjs +5 -8
  13. package/dist/billing.d.cts +1 -9
  14. package/dist/billing.d.ts +1 -9
  15. package/dist/billing.js +5 -8
  16. package/dist/commerce.cjs +15 -23
  17. package/dist/commerce.d.cts +2 -16
  18. package/dist/commerce.d.ts +2 -16
  19. package/dist/commerce.js +15 -23
  20. package/dist/{format-DLhno7eX.cjs → format-92fzvTXY.cjs} +9 -9
  21. package/dist/{format-BdPnijvn.js → format-BJC513u4.js} +9 -9
  22. package/dist/fx.cjs +12 -18
  23. package/dist/fx.d.cts +5 -15
  24. package/dist/fx.d.ts +5 -15
  25. package/dist/fx.js +12 -18
  26. package/dist/index.cjs +10 -12
  27. package/dist/index.d.cts +17 -23
  28. package/dist/index.d.ts +17 -23
  29. package/dist/index.js +10 -12
  30. package/dist/input.cjs +7 -10
  31. package/dist/input.d.cts +16 -22
  32. package/dist/input.d.ts +16 -22
  33. package/dist/input.js +7 -10
  34. package/dist/{iso-minor-wSwJN57T.cjs → iso-minor-DyNjT9A1.cjs} +2 -3
  35. package/dist/{iso-minor-CqkWDxHS.js → iso-minor-odkY-e6I.js} +2 -3
  36. package/dist/{medusa-lRY9xlsf.cjs → medusa-CzVK0bth.cjs} +3 -4
  37. package/dist/{medusa-DBXJXXvF.d.ts → medusa-DofdvIgQ.d.cts} +1 -3
  38. package/dist/{medusa-4K8N1pUc.d.cts → medusa-DrbYmD2Y.d.ts} +1 -3
  39. package/dist/{medusa-DqJY1qpj.js → medusa-pKGlImn9.js} +3 -4
  40. package/dist/{money-B-3aFjNJ.d.cts → money-BkMeYDEW.d.cts} +0 -6
  41. package/dist/{money-B-3aFjNJ.d.ts → money-BkMeYDEW.d.ts} +0 -6
  42. package/dist/{money-WhnGiI00.js → money-BxbAw7BP.js} +7 -15
  43. package/dist/{money-B3wH_Z4S.cjs → money-DWBjuuEK.cjs} +7 -15
  44. package/dist/{number-text-DE-q4jO5.js → number-text-Bj-gZXiF.js} +3 -4
  45. package/dist/{number-text-BWu67jUq.cjs → number-text-CWuVwrlg.cjs} +3 -4
  46. package/dist/{own-oP9DXFWv.cjs → own-C5imDkyB.cjs} +1 -2
  47. package/dist/{own-D7544D3k.js → own-DHxqIYqL.js} +1 -2
  48. package/dist/{percent-D1VB9xXG.js → percent-CB3Ixjc_.js} +2 -3
  49. package/dist/{percent-C0InC2t2.cjs → percent-DABHiSBs.cjs} +2 -3
  50. package/dist/{rate-DBPiYgT1.d.ts → rate-BvvZUdSu.d.ts} +1 -3
  51. package/dist/{rate-tqK8ijG0.d.cts → rate-CEakW3ia.d.cts} +1 -3
  52. package/dist/{rate-CVeMii4a.cjs → rate-CEjWTATc.cjs} +3 -4
  53. package/dist/{rate-DicStBue.js → rate-D6S2_wgZ.js} +3 -4
  54. package/dist/{reporting-tpGJbqYp.d.ts → reporting-DFNyDBdi.d.cts} +2 -4
  55. package/dist/{reporting-CG-ai2sM.d.cts → reporting-jIBILvnr.d.ts} +2 -4
  56. package/dist/{retail-DRUTTQoJ.d.ts → retail-B04CjW3b.d.ts} +1 -3
  57. package/dist/{retail-Cml8YSKg.cjs → retail-CYGPU4ea.cjs} +4 -5
  58. package/dist/{retail-C_BPLvMj.d.cts → retail-CmEyJQOH.d.cts} +1 -3
  59. package/dist/{retail-1mu888J1.js → retail-DXgs11ov.js} +4 -5
  60. package/dist/{rounding-DHBtNCHG.cjs → rounding-4QKTRbMQ.cjs} +2 -3
  61. package/dist/{rounding-g9rvye0k.js → rounding-CA1PVP3b.js} +2 -3
  62. package/dist/sql.cjs +9 -15
  63. package/dist/sql.d.cts +2 -12
  64. package/dist/sql.d.ts +2 -12
  65. package/dist/sql.js +9 -15
  66. package/dist/testing.cjs +39198 -12
  67. package/dist/testing.d.cts +20 -13
  68. package/dist/testing.d.ts +20 -13
  69. package/dist/testing.js +39198 -13
  70. package/dist/{wire-sW0yzqth.js → wire-B4QU8O3W.js} +350 -93
  71. package/dist/{wire-CaUN9Vf_.d.ts → wire-CVNicirK.d.ts} +165 -46
  72. package/dist/{wire-xjYXv4go.d.cts → wire-CtNJmWVP.d.cts} +165 -46
  73. package/dist/{wire-Bhuut8cW.cjs → wire-u2tmHY0Y.cjs} +403 -92
  74. package/dist/wire.cjs +10 -1
  75. package/dist/wire.d.cts +2 -2
  76. package/dist/wire.d.ts +2 -2
  77. package/dist/wire.js +1 -2
  78. package/package.json +4 -3
package/dist/fx.d.cts CHANGED
@@ -1,9 +1,8 @@
1
- import { R as DecimalText, i as Money, z as RoundingMode } from "./money-B-3aFjNJ.cjs";
2
- import { n as priceRoundingParams, r as roundRetail, t as RetailRounding } from "./retail-C_BPLvMj.cjs";
3
- import { a as RateRow, c as rate, d as rateFromRow, f as rateToDecimal, i as RateFromDecimalOptions, l as rateEquals, n as RATE_REF, o as crossRate, p as rateToNumber, r as Rate, s as invertRate, t as RATE_BOUNDS, u as rateFromDecimal } from "./rate-tqK8ijG0.cjs";
4
- import { i as toReporting, n as ReportingTotal, r as storeFactors, t as FactorTable } from "./reporting-CG-ai2sM.cjs";
5
- import { n as MoneyByCurrency } from "./medusa-4K8N1pUc.cjs";
6
- //#region src/fx/convert.d.ts
1
+ import { R as DecimalText, i as Money, z as RoundingMode } from "./money-BkMeYDEW.cjs";
2
+ import { n as priceRoundingParams, r as roundRetail, t as RetailRounding } from "./retail-CmEyJQOH.cjs";
3
+ import { a as RateRow, c as rate, d as rateFromRow, f as rateToDecimal, i as RateFromDecimalOptions, l as rateEquals, n as RATE_REF, o as crossRate, p as rateToNumber, r as Rate, s as invertRate, t as RATE_BOUNDS, u as rateFromDecimal } from "./rate-CEakW3ia.cjs";
4
+ import { i as toReporting, n as ReportingTotal, r as storeFactors, t as FactorTable } from "./reporting-DFNyDBdi.cjs";
5
+ import { n as MoneyByCurrency } from "./medusa-DofdvIgQ.cjs";
7
6
  /**
8
7
  * The factor taking a stored `from` amount to a stored `to` amount for the major rate `r`
9
8
  * (1 from = r to): `{ r.n x storageScale(to), r.d x storageScale(from) }`. Replaces Medusa
@@ -31,8 +30,6 @@ export declare function convert(m: Money, to: string, r: Rate, options?: Convert
31
30
  * 150000 against USD 1000 gives 150). Both must be positive, else `rate_invalid`.
32
31
  */
33
32
  export declare function impliedRate(a: Money, b: Money): Rate;
34
- //#endregion
35
- //#region src/fx/format-rate.d.ts
36
33
  /**
37
34
  * `'1 USD = 83.42 INR'`. `decimals: 'auto'` (default) shows 4 significant digits with at
38
35
  * least 2 and at most 8 fraction digits; a number fixes them. Rounded half-up exactly, then
@@ -42,8 +39,6 @@ export declare function formatRate(r: Rate, from: string, to: string, options?:
42
39
  decimals?: 'auto' | number;
43
40
  locale?: string;
44
41
  }): string;
45
- //#endregion
46
- //#region src/fx/plausibility.d.ts
47
42
  /** Medusa PRICE_SEED_RATE_MAX_DEVIATION's default. */
48
43
  export declare const DEFAULT_RATE_MAX_DEVIATION = 2;
49
44
  /** chooseFactor's tolerance between the conventional factor and the observed median. */
@@ -106,8 +101,6 @@ export declare function rateConsensus(rates: readonly Rate[], options?: {
106
101
  median: Rate | null;
107
102
  accepted: boolean[];
108
103
  };
109
- //#endregion
110
- //#region src/fx/settings.d.ts
111
104
  export declare const RATE_MODES: readonly ["manual", "dynamic"];
112
105
  export declare const PRICE_ROUNDINGS: readonly ["none", "nearest"];
113
106
  /** `store_currency_rate.rate_mode` as readers coerce it: `'manual'` exactly, else `'dynamic'`. */
@@ -137,8 +130,6 @@ export declare function resolveMoneyByCurrency(setting: MoneyByCurrency, currenc
137
130
  money: Money;
138
131
  source: 'listed' | 'fallback';
139
132
  } | null;
140
- //#endregion
141
- //#region src/fx/tables.d.ts
142
133
  /** 1 USD = rate units of the currency, exact (see data/pegs.ts for the sources). Upper-case keys. */
143
134
  export declare const USD_PEGS: Readonly<Record<string, Rate>>;
144
135
  /** A feed's rate table with lower-case keys and only finite positive numbers kept (Medusa `lowerKeys`). Never throws. */
@@ -153,5 +144,4 @@ export declare function mergeRateTables(primary: Readonly<Record<string, number>
153
144
  * gives 1/1; anything else null.
154
145
  */
155
146
  export declare function pegFallback(from: string, to: string, ratesPerUsd: Readonly<Record<string, number>>, pegs?: Readonly<Record<string, Rate>>): Rate | null;
156
- //#endregion
157
147
  export { type ConvertOptions, type FactorTable, type MoneyByCurrencyFallback, RATE_BOUNDS, RATE_REF, type Rate, type RateClassification, type RateFromDecimalOptions, type RateReference, type RateRow, type ReportingTotal, type RetailRounding, crossRate, invertRate, priceRoundingParams, rate, rateEquals, rateFromDecimal, rateFromRow, rateToDecimal, rateToNumber, roundRetail, storeFactors, toReporting };
package/dist/fx.d.ts CHANGED
@@ -1,9 +1,8 @@
1
- import { R as DecimalText, i as Money, z as RoundingMode } from "./money-B-3aFjNJ.js";
2
- import { n as priceRoundingParams, r as roundRetail, t as RetailRounding } from "./retail-DRUTTQoJ.js";
3
- import { a as RateRow, c as rate, d as rateFromRow, f as rateToDecimal, i as RateFromDecimalOptions, l as rateEquals, n as RATE_REF, o as crossRate, p as rateToNumber, r as Rate, s as invertRate, t as RATE_BOUNDS, u as rateFromDecimal } from "./rate-DBPiYgT1.js";
4
- import { i as toReporting, n as ReportingTotal, r as storeFactors, t as FactorTable } from "./reporting-tpGJbqYp.js";
5
- import { n as MoneyByCurrency } from "./medusa-DBXJXXvF.js";
6
- //#region src/fx/convert.d.ts
1
+ import { R as DecimalText, i as Money, z as RoundingMode } from "./money-BkMeYDEW.js";
2
+ import { n as priceRoundingParams, r as roundRetail, t as RetailRounding } from "./retail-B04CjW3b.js";
3
+ import { a as RateRow, c as rate, d as rateFromRow, f as rateToDecimal, i as RateFromDecimalOptions, l as rateEquals, n as RATE_REF, o as crossRate, p as rateToNumber, r as Rate, s as invertRate, t as RATE_BOUNDS, u as rateFromDecimal } from "./rate-BvvZUdSu.js";
4
+ import { i as toReporting, n as ReportingTotal, r as storeFactors, t as FactorTable } from "./reporting-jIBILvnr.js";
5
+ import { n as MoneyByCurrency } from "./medusa-DrbYmD2Y.js";
7
6
  /**
8
7
  * The factor taking a stored `from` amount to a stored `to` amount for the major rate `r`
9
8
  * (1 from = r to): `{ r.n x storageScale(to), r.d x storageScale(from) }`. Replaces Medusa
@@ -31,8 +30,6 @@ export declare function convert(m: Money, to: string, r: Rate, options?: Convert
31
30
  * 150000 against USD 1000 gives 150). Both must be positive, else `rate_invalid`.
32
31
  */
33
32
  export declare function impliedRate(a: Money, b: Money): Rate;
34
- //#endregion
35
- //#region src/fx/format-rate.d.ts
36
33
  /**
37
34
  * `'1 USD = 83.42 INR'`. `decimals: 'auto'` (default) shows 4 significant digits with at
38
35
  * least 2 and at most 8 fraction digits; a number fixes them. Rounded half-up exactly, then
@@ -42,8 +39,6 @@ export declare function formatRate(r: Rate, from: string, to: string, options?:
42
39
  decimals?: 'auto' | number;
43
40
  locale?: string;
44
41
  }): string;
45
- //#endregion
46
- //#region src/fx/plausibility.d.ts
47
42
  /** Medusa PRICE_SEED_RATE_MAX_DEVIATION's default. */
48
43
  export declare const DEFAULT_RATE_MAX_DEVIATION = 2;
49
44
  /** chooseFactor's tolerance between the conventional factor and the observed median. */
@@ -106,8 +101,6 @@ export declare function rateConsensus(rates: readonly Rate[], options?: {
106
101
  median: Rate | null;
107
102
  accepted: boolean[];
108
103
  };
109
- //#endregion
110
- //#region src/fx/settings.d.ts
111
104
  export declare const RATE_MODES: readonly ["manual", "dynamic"];
112
105
  export declare const PRICE_ROUNDINGS: readonly ["none", "nearest"];
113
106
  /** `store_currency_rate.rate_mode` as readers coerce it: `'manual'` exactly, else `'dynamic'`. */
@@ -137,8 +130,6 @@ export declare function resolveMoneyByCurrency(setting: MoneyByCurrency, currenc
137
130
  money: Money;
138
131
  source: 'listed' | 'fallback';
139
132
  } | null;
140
- //#endregion
141
- //#region src/fx/tables.d.ts
142
133
  /** 1 USD = rate units of the currency, exact (see data/pegs.ts for the sources). Upper-case keys. */
143
134
  export declare const USD_PEGS: Readonly<Record<string, Rate>>;
144
135
  /** A feed's rate table with lower-case keys and only finite positive numbers kept (Medusa `lowerKeys`). Never throws. */
@@ -153,5 +144,4 @@ export declare function mergeRateTables(primary: Readonly<Record<string, number>
153
144
  * gives 1/1; anything else null.
154
145
  */
155
146
  export declare function pegFallback(from: string, to: string, ratesPerUsd: Readonly<Record<string, number>>, pegs?: Readonly<Record<string, Rate>>): Rate | null;
156
- //#endregion
157
147
  export { type ConvertOptions, type FactorTable, type MoneyByCurrencyFallback, RATE_BOUNDS, RATE_REF, type Rate, type RateClassification, type RateFromDecimalOptions, type RateReference, type RateRow, type ReportingTotal, type RetailRounding, crossRate, invertRate, priceRoundingParams, rate, rateEquals, rateFromDecimal, rateFromRow, rateToDecimal, rateToNumber, roundRetail, storeFactors, toReporting };
package/dist/fx.js CHANGED
@@ -1,10 +1,10 @@
1
- import { $ as describeValue, B as decimalOf, E as resolveCurrency, J as compareRatio, M as resolveLocale, Q as MoneyError, X as mulDiv, Y as gcd, Z as ratioToDecimal, it as formatDecimal, j as numberFormat, n as fromMajor, nt as decimalFromNumber, pt as toDecimalText, s as storedDecimal, t as boundedMoney, ut as pow10, y as findCurrency } from "./money-WhnGiI00.js";
2
- import { t as mulDivToUnit } from "./rounding-g9rvye0k.js";
3
- import { t as hasOwnKey } from "./own-D7544D3k.js";
4
- import { r as moneyFor } from "./medusa-DqJY1qpj.js";
5
- import { a as invertRate, c as rateFromDecimal, d as rateToNumber, i as crossRate, l as rateFromRow, n as RATE_REF, o as rate, r as checkRate, s as rateEquals, t as RATE_BOUNDS, u as rateToDecimal } from "./rate-DicStBue.js";
6
- import { n as retailUnits, r as roundRetail, t as priceRoundingParams } from "./retail-1mu888J1.js";
7
- //#region src/fx/convert.ts
1
+ import { $ as describeValue, B as decimalOf, E as resolveCurrency, J as compareRatio, M as resolveLocale, Q as MoneyError, X as mulDiv, Y as gcd, Z as ratioToDecimal, it as formatDecimal, j as numberFormat, n as fromMajor, nt as decimalFromNumber, pt as toDecimalText, s as storedDecimal, t as boundedMoney, ut as pow10, y as findCurrency } from "./money-BxbAw7BP.js";
2
+ import { t as mulDivToUnit } from "./rounding-CA1PVP3b.js";
3
+ import { t as hasOwnKey } from "./own-DHxqIYqL.js";
4
+ import { r as moneyFor } from "./medusa-pKGlImn9.js";
5
+ import { a as invertRate, c as rateFromDecimal, d as rateToNumber, i as crossRate, l as rateFromRow, n as RATE_REF, o as rate, r as checkRate, s as rateEquals, t as RATE_BOUNDS, u as rateToDecimal } from "./rate-D6S2_wgZ.js";
6
+ import { n as retailUnits, r as roundRetail, t as priceRoundingParams } from "./retail-DXgs11ov.js";
7
+ // src/fx/convert.ts
8
8
  const infoOf = (code) => resolveCurrency(code, { allowHistoric: true });
9
9
  /**
10
10
  * The factor taking a stored `from` amount to a stored `to` amount for the major rate `r`
@@ -46,8 +46,7 @@ function impliedRate(a, b) {
46
46
  denominator: denominator / divisor
47
47
  };
48
48
  }
49
- //#endregion
50
- //#region src/fx/format-rate.ts
49
+ // src/fx/format-rate.ts
51
50
  /** `floor(log10(n / d))` of a positive ratio, exactly. */
52
51
  function exponentOf(n, d) {
53
52
  let e = n.toString().length - d.toString().length;
@@ -76,8 +75,7 @@ function formatRate(r, from, to, options = {}) {
76
75
  maximumFractionDigits: digits
77
76
  }).format(asIntlValue(formatDecimal(value)))} ${toCode}`;
78
77
  }
79
- //#endregion
80
- //#region src/fx/plausibility.ts
78
+ // src/fx/plausibility.ts
81
79
  /** Medusa PRICE_SEED_RATE_MAX_DEVIATION's default. */
82
80
  const DEFAULT_RATE_MAX_DEVIATION = 2;
83
81
  /** chooseFactor's tolerance between the conventional factor and the observed median. */
@@ -205,8 +203,7 @@ function rateConsensus(rates, options = {}) {
205
203
  })
206
204
  };
207
205
  }
208
- //#endregion
209
- //#region src/fx/reporting.ts
206
+ // src/fx/reporting.ts
210
207
  const FACTOR_DIGITS = 20;
211
208
  /**
212
209
  * The reporting factors of a store whose locked rates say `1 default = n/d <code>`:
@@ -259,8 +256,7 @@ function toReporting(items, table) {
259
256
  missing: [...missing].sort()
260
257
  };
261
258
  }
262
- //#endregion
263
- //#region src/fx/settings.ts
259
+ // src/fx/settings.ts
264
260
  const RATE_MODES = ["manual", "dynamic"];
265
261
  const PRICE_ROUNDINGS = ["none", "nearest"];
266
262
  /** `store_currency_rate.rate_mode` as readers coerce it: `'manual'` exactly, else `'dynamic'`. */
@@ -298,8 +294,7 @@ function resolveMoneyByCurrency(setting, currency, options) {
298
294
  }
299
295
  return null;
300
296
  }
301
- //#endregion
302
- //#region src/fx/tables.ts
297
+ // src/fx/tables.ts
303
298
  /** 1 USD = rate units of the currency, exact (see data/pegs.ts for the sources). Upper-case keys. */
304
299
  const USD_PEGS = Object.freeze(Object.fromEntries(Object.entries({
305
300
  AED: [36725n, 10000n],
@@ -370,5 +365,4 @@ function pegFallback(from, to, ratesPerUsd, pegs = USD_PEGS) {
370
365
  const fromPeg = own(pegs, f);
371
366
  return fromPeg !== void 0 && t === "USD" ? invertRate(fromPeg) : null;
372
367
  }
373
- //#endregion
374
368
  export { DEFAULT_RATE_MAX_DEVIATION, FACTOR_TOLERANCE, PRICE_ROUNDINGS, RATE_BOUNDS, RATE_MODES, RATE_REF, USD_PEGS, classifyRate, confirmStoredFactor, convert, convertFactor, crossRate, deviationFactor, formatRate, impliedRate, invertRate, mergeRateTables, parsePriceRounding, parseRateMode, pegFallback, priceRoundingParams, rate, rateConsensus, rateEquals, rateFromDecimal, rateFromRow, rateToDecimal, rateToNumber, resolveMoneyByCurrency, roundRetail, sanitizeRateTable, storeFactors, toReporting };
package/dist/index.cjs CHANGED
@@ -1,13 +1,13 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_money = require("./money-B3wH_Z4S.cjs");
3
- const require_rounding = require("./rounding-DHBtNCHG.cjs");
4
- const require_allocate = require("./allocate-CZRg4TOP.cjs");
5
- const require_arithmetic = require("./arithmetic-DjT4Kzgt.cjs");
6
- const require_own = require("./own-oP9DXFWv.cjs");
7
- const require_format = require("./format-DLhno7eX.cjs");
8
- const require_iso_minor = require("./iso-minor-wSwJN57T.cjs");
9
- const require_medusa = require("./medusa-lRY9xlsf.cjs");
10
- //#region src/data/countries.ts
2
+ const require_money = require("./money-DWBjuuEK.cjs");
3
+ const require_rounding = require("./rounding-4QKTRbMQ.cjs");
4
+ const require_allocate = require("./allocate-AusholrC.cjs");
5
+ const require_arithmetic = require("./arithmetic-D8A6IeZ0.cjs");
6
+ const require_own = require("./own-C5imDkyB.cjs");
7
+ const require_format = require("./format-92fzvTXY.cjs");
8
+ const require_iso_minor = require("./iso-minor-DyNjT9A1.cjs");
9
+ const require_medusa = require("./medusa-CzVK0bth.cjs");
10
+ // src/data/countries.ts
11
11
  const COUNTRY_CURRENCY = {
12
12
  AC: "SHP",
13
13
  AD: "EUR",
@@ -265,15 +265,13 @@ const COUNTRY_CURRENCY = {
265
265
  ZM: "ZMW",
266
266
  ZW: "ZWG"
267
267
  };
268
- //#endregion
269
- //#region src/country.ts
268
+ // src/country.ts
270
269
  /** The current legal tender of an ISO 3166 country (`'US'` or `'us'`), or null when unknown. Never guesses USD. */
271
270
  function defaultCurrencyForCountry(country) {
272
271
  if (typeof country !== "string") return null;
273
272
  const key = country.toUpperCase();
274
273
  return require_own.hasOwnKey(COUNTRY_CURRENCY, key) ? COUNTRY_CURRENCY[key] : null;
275
274
  }
276
- //#endregion
277
275
  exports.CURRENCIES = require_money.CURRENCIES;
278
276
  exports.MoneyError = require_money.MoneyError;
279
277
  exports.add = require_arithmetic.add;
package/dist/index.d.cts CHANGED
@@ -1,6 +1,5 @@
1
- import { A as isCurrencyCode, C as currencyInfo, D as currencySymbol, E as currencyOptions, F as sameCurrency, I as storageDigits, L as storageScale, M as medusaCurrencyCode, N as medusaEpsilon, O as displayDigits, P as parseCurrencyCode, R as DecimalText, S as currencyCode, T as currencyName, _ as CurrencyCodeOptions, a as ReadStoredOptions, b as FractionDigits, c as ToMajorDecimalOptions, d as money, f as readStored, g as CurrencyCode, h as CURRENCIES, i as Money, j as localeForCurrency, k as firstCurrency, l as fromMajor, m as toMajorNumber, n as FromMajorOptions, o as StoredAmount, p as toMajorDecimal, r as MajorDecimal, s as StoredAmountOptions, t as FractionalMoney, u as isStoredAmount, v as CurrencyInfo, w as currencyLabel, x as StorageScale, y as CurrencyStatus, z as RoundingMode } from "./money-B-3aFjNJ.cjs";
2
- import { a as isPositiveAmount, c as readCalculatedPrice, d as readStoredLiteral, f as toMedusaAmountInput, i as ReadStoredDecimalOptions, l as readStoredDecimal, n as MoneyByCurrency, o as moneyByCurrency, p as toMedusaRaw, r as PriceLike, s as moneyFor, t as MedusaRaw, u as readStoredField } from "./medusa-4K8N1pUc.cjs";
3
- //#region src/allocate.d.ts
1
+ import { A as isCurrencyCode, C as currencyInfo, D as currencySymbol, E as currencyOptions, F as sameCurrency, I as storageDigits, L as storageScale, M as medusaCurrencyCode, N as medusaEpsilon, O as displayDigits, P as parseCurrencyCode, R as DecimalText, S as currencyCode, T as currencyName, _ as CurrencyCodeOptions, a as ReadStoredOptions, b as FractionDigits, c as ToMajorDecimalOptions, d as money, f as readStored, g as CurrencyCode, h as CURRENCIES, i as Money, j as localeForCurrency, k as firstCurrency, l as fromMajor, m as toMajorNumber, n as FromMajorOptions, o as StoredAmount, p as toMajorDecimal, r as MajorDecimal, s as StoredAmountOptions, t as FractionalMoney, u as isStoredAmount, v as CurrencyInfo, w as currencyLabel, x as StorageScale, y as CurrencyStatus, z as RoundingMode } from "./money-BkMeYDEW.cjs";
2
+ import { a as isPositiveAmount, c as readCalculatedPrice, d as readStoredLiteral, f as toMedusaAmountInput, i as ReadStoredDecimalOptions, l as readStoredDecimal, n as MoneyByCurrency, o as moneyByCurrency, p as toMedusaRaw, r as PriceLike, s as moneyFor, t as MedusaRaw, u as readStoredField } from "./medusa-DofdvIgQ.cjs";
4
3
  /**
5
4
  * Where the rounding remainder goes:
6
5
  * - `'largest-remainder'` (default; promotion parity engine): floor every share, then +1 unit
@@ -67,8 +66,6 @@ interface UnitPricePart {
67
66
  export declare function splitUnitPrice(net: Money, quantity: number, options?: {
68
67
  unit?: 'storage' | 'currency';
69
68
  }): UnitPricePart[];
70
- //#endregion
71
- //#region src/rounding.d.ts
72
69
  /**
73
70
  * - `'storage'`: one storage unit (USD 1 cent, JPY 1/100 yen).
74
71
  * - `'currency'`: the smallest unit the currency stores, 10^-storageDigits major (JPY 1 yen
@@ -99,8 +96,6 @@ export declare function roundMajor(major: number | DecimalText, currency: string
99
96
  digits?: 'display' | 'storage';
100
97
  rounding?: RoundingMode;
101
98
  }): number;
102
- //#endregion
103
- //#region src/arithmetic.d.ts
104
99
  /** An exact ratio of integers (`{ numerator: 1, denominator: 3 }`). */
105
100
  interface Ratio {
106
101
  readonly numerator: number | bigint;
@@ -145,12 +140,8 @@ export declare function within(a: Money, b: Money, tolerance: Money, options?: {
145
140
  }): boolean;
146
141
  /** `d = a - b`; `d` below `tolerance` counts as rounding and gives 0, else `d` (Stripe `refundSyncDelta`). */
147
142
  export declare function excessOver(a: Money, b: Money, tolerance: Money): Money;
148
- //#endregion
149
- //#region src/country.d.ts
150
143
  /** The current legal tender of an ISO 3166 country (`'US'` or `'us'`), or null when unknown. Never guesses USD. */
151
144
  export declare function defaultCurrencyForCountry(country: string): CurrencyCode | null;
152
- //#endregion
153
- //#region src/decimal-text.d.ts
154
145
  /** Anything the family takes as a value. */
155
146
  type DecimalInput = DecimalText | string | number | bigint;
156
147
  /** Canonical DecimalText of `input` (`'4300.00'` gives `'4300'`, `0.1 + 0.2` gives `'0.30000000000000004'`). See `decimalOf` for what is refused. */
@@ -205,8 +196,6 @@ export declare function decimalClamp(a: DecimalText | string, bounds: {
205
196
  export declare function decimalWithin(a: DecimalText | string, b: DecimalText | string, tolerance: DecimalText | string, options?: {
206
197
  inclusive?: boolean;
207
198
  }): boolean;
208
- //#endregion
209
- //#region src/errors.d.ts
210
199
  /**
211
200
  * Why a money operation refused its input:
212
201
  * - `currency_invalid`: not a currency this package knows (or a retired one where only active codes are allowed)
@@ -231,8 +220,6 @@ export declare class MoneyError extends Error {
231
220
  readonly field?: string;
232
221
  constructor(code: MoneyErrorCode, message: string, options?: MoneyErrorOptions);
233
222
  }
234
- //#endregion
235
- //#region src/format.d.ts
236
223
  interface FormatMoneyOptions {
237
224
  /** Default `'en-US'`; an unsupported or malformed tag falls back to it. */
238
225
  locale?: string;
@@ -248,16 +235,26 @@ interface FormatMoneyOptions {
248
235
  signDisplay?: 'auto' | 'always' | 'exceptZero';
249
236
  /** Default `'-'`; `'−'` (U+2212) replaces the leading ASCII minus. */
250
237
  minusSign?: '-' | '−';
238
+ /**
239
+ * How the amount is rounded to the digits shown: `'half-up'` (default) or `'down'` (toward
240
+ * zero), for an upper bound that must not read above itself: a refund cap of HUF 435050
241
+ * (4,350.50) shows `'HUF 4,350'` with `'down'`, never 4,351. `formatStored` rounds a fractional
242
+ * amount to a storage unit the same way first.
243
+ */
244
+ rounding?: DisplayRounding;
251
245
  }
246
+ /** The roundings `formatMoney` and `formatStored` take. */
247
+ type DisplayRounding = Extract<RoundingMode, 'half-up' | 'down'>;
252
248
  /**
253
249
  * Money for people: `'$1,234.50'`, `'¥1,200'`, `'KWD 1.005'`, `'-€5.00'`. Locale, currency
254
- * display, digits and sign are explicit options; the active app locale is the caller's to
255
- * pass. If Intl throws, `'<CODE> <decimal>'`.
250
+ * display, digits, sign and rounding (half-up by default, `'down'` for caps) are explicit
251
+ * options; the active app locale is the caller's to pass. If Intl throws, `'<CODE> <decimal>'`.
256
252
  */
257
253
  export declare function formatMoney(m: Money, options?: FormatMoneyOptions): string;
258
254
  /**
259
255
  * A stored amount that may be fractional (a Medusa total, 107.8175; a percentage promotion) for
260
- * people: rounded half-up to a whole storage unit (`roundToUnit`), then `formatMoney` with `options`.
256
+ * people: rounded to a whole storage unit by `options.rounding` (`roundToUnit`; half-up by default,
257
+ * `'down'` toward zero for a cap), then `formatMoney` with `options`.
261
258
  * A number must be finite; text is plain decimal; an unknown currency throws `currency_invalid`.
262
259
  */
263
260
  export declare function formatStored(amount: number | DecimalText, currency: string, options?: FormatMoneyOptions): string;
@@ -265,7 +262,7 @@ export declare function formatStored(amount: number | DecimalText, currency: str
265
262
  * Like `formatMoney` below `threshold` major units (default 10000, by magnitude); at or above
266
263
  * it, compact short notation with `maximumSignificantDigits` (default 3): `'$12.3K'`.
267
264
  */
268
- export declare function formatMoneyCompact(m: Money, options?: FormatMoneyOptions & {
265
+ export declare function formatMoneyCompact(m: Money, options?: Omit<FormatMoneyOptions, 'rounding'> & {
269
266
  threshold?: number;
270
267
  maximumSignificantDigits?: number;
271
268
  }): string;
@@ -278,8 +275,6 @@ export declare function formatMoneyRange(low: Money, high: Money | null, options
278
275
  * same rounding as `formatMoneyCompact` (`1234567` gives `'$1.23M'`).
279
276
  */
280
277
  export declare function moneyAxisFormatter(currency: string, options?: Pick<FormatMoneyOptions, 'locale' | 'currencyDisplay'>): (major: number) => string;
281
- //#endregion
282
- //#region src/iso-minor.d.ts
283
278
  /**
284
279
  * ISO minor units at the display digits: `round(major x 10^displayDigits)` with `rounding`
285
280
  * (default half-up). JPY 150000 gives 1500, KWD 1005 gives 1005, IQD 10000 gives 10, HUF
@@ -296,5 +291,4 @@ export declare function toIsoMinor(m: Money, options?: {
296
291
  export declare function fromIsoMinor(value: number | string, currency: string, options?: {
297
292
  digits?: FractionDigits;
298
293
  }): Money;
299
- //#endregion
300
- export { type AllocateOptions, type AllocationStrategy, type AllocationWeight, type AmountUnit, CURRENCIES, type CurrencyCode, type CurrencyCodeOptions, type CurrencyInfo, type CurrencyStatus, type DecimalInput, type DecimalText, type FormatMoneyOptions, type FractionDigits, type FractionalMoney, type FromMajorOptions, type MajorDecimal, type MedusaRaw, type Money, type MoneyByCurrency, type MoneyErrorCode, type MoneyErrorOptions, type PriceLike, type Ratio, type ReadStoredDecimalOptions, type ReadStoredOptions, type RoundToUnitOptions, type RoundingMode, type StorageScale, type StoredAmount, type StoredAmountOptions, type ToMajorDecimalOptions, type UnitPricePart, type WaterfallResult, currencyCode, currencyInfo, currencyLabel, currencyName, currencyOptions, currencySymbol, displayDigits, firstCurrency, fromMajor, isCurrencyCode, isPositiveAmount, isStoredAmount, localeForCurrency, medusaCurrencyCode, medusaEpsilon, money, moneyByCurrency, moneyFor, parseCurrencyCode, readCalculatedPrice, readStored, readStoredDecimal, readStoredField, readStoredLiteral, sameCurrency, storageDigits, storageScale, toMajorDecimal, toMajorNumber, toMedusaAmountInput, toMedusaRaw };
294
+ export { type AllocateOptions, type AllocationStrategy, type AllocationWeight, type AmountUnit, CURRENCIES, type CurrencyCode, type CurrencyCodeOptions, type CurrencyInfo, type CurrencyStatus, type DecimalInput, type DecimalText, type DisplayRounding, type FormatMoneyOptions, type FractionDigits, type FractionalMoney, type FromMajorOptions, type MajorDecimal, type MedusaRaw, type Money, type MoneyByCurrency, type MoneyErrorCode, type MoneyErrorOptions, type PriceLike, type Ratio, type ReadStoredDecimalOptions, type ReadStoredOptions, type RoundToUnitOptions, type RoundingMode, type StorageScale, type StoredAmount, type StoredAmountOptions, type ToMajorDecimalOptions, type UnitPricePart, type WaterfallResult, currencyCode, currencyInfo, currencyLabel, currencyName, currencyOptions, currencySymbol, displayDigits, firstCurrency, fromMajor, isCurrencyCode, isPositiveAmount, isStoredAmount, localeForCurrency, medusaCurrencyCode, medusaEpsilon, money, moneyByCurrency, moneyFor, parseCurrencyCode, readCalculatedPrice, readStored, readStoredDecimal, readStoredField, readStoredLiteral, sameCurrency, storageDigits, storageScale, toMajorDecimal, toMajorNumber, toMedusaAmountInput, toMedusaRaw };
package/dist/index.d.ts CHANGED
@@ -1,6 +1,5 @@
1
- import { A as isCurrencyCode, C as currencyInfo, D as currencySymbol, E as currencyOptions, F as sameCurrency, I as storageDigits, L as storageScale, M as medusaCurrencyCode, N as medusaEpsilon, O as displayDigits, P as parseCurrencyCode, R as DecimalText, S as currencyCode, T as currencyName, _ as CurrencyCodeOptions, a as ReadStoredOptions, b as FractionDigits, c as ToMajorDecimalOptions, d as money, f as readStored, g as CurrencyCode, h as CURRENCIES, i as Money, j as localeForCurrency, k as firstCurrency, l as fromMajor, m as toMajorNumber, n as FromMajorOptions, o as StoredAmount, p as toMajorDecimal, r as MajorDecimal, s as StoredAmountOptions, t as FractionalMoney, u as isStoredAmount, v as CurrencyInfo, w as currencyLabel, x as StorageScale, y as CurrencyStatus, z as RoundingMode } from "./money-B-3aFjNJ.js";
2
- import { a as isPositiveAmount, c as readCalculatedPrice, d as readStoredLiteral, f as toMedusaAmountInput, i as ReadStoredDecimalOptions, l as readStoredDecimal, n as MoneyByCurrency, o as moneyByCurrency, p as toMedusaRaw, r as PriceLike, s as moneyFor, t as MedusaRaw, u as readStoredField } from "./medusa-DBXJXXvF.js";
3
- //#region src/allocate.d.ts
1
+ import { A as isCurrencyCode, C as currencyInfo, D as currencySymbol, E as currencyOptions, F as sameCurrency, I as storageDigits, L as storageScale, M as medusaCurrencyCode, N as medusaEpsilon, O as displayDigits, P as parseCurrencyCode, R as DecimalText, S as currencyCode, T as currencyName, _ as CurrencyCodeOptions, a as ReadStoredOptions, b as FractionDigits, c as ToMajorDecimalOptions, d as money, f as readStored, g as CurrencyCode, h as CURRENCIES, i as Money, j as localeForCurrency, k as firstCurrency, l as fromMajor, m as toMajorNumber, n as FromMajorOptions, o as StoredAmount, p as toMajorDecimal, r as MajorDecimal, s as StoredAmountOptions, t as FractionalMoney, u as isStoredAmount, v as CurrencyInfo, w as currencyLabel, x as StorageScale, y as CurrencyStatus, z as RoundingMode } from "./money-BkMeYDEW.js";
2
+ import { a as isPositiveAmount, c as readCalculatedPrice, d as readStoredLiteral, f as toMedusaAmountInput, i as ReadStoredDecimalOptions, l as readStoredDecimal, n as MoneyByCurrency, o as moneyByCurrency, p as toMedusaRaw, r as PriceLike, s as moneyFor, t as MedusaRaw, u as readStoredField } from "./medusa-DrbYmD2Y.js";
4
3
  /**
5
4
  * Where the rounding remainder goes:
6
5
  * - `'largest-remainder'` (default; promotion parity engine): floor every share, then +1 unit
@@ -67,8 +66,6 @@ interface UnitPricePart {
67
66
  export declare function splitUnitPrice(net: Money, quantity: number, options?: {
68
67
  unit?: 'storage' | 'currency';
69
68
  }): UnitPricePart[];
70
- //#endregion
71
- //#region src/rounding.d.ts
72
69
  /**
73
70
  * - `'storage'`: one storage unit (USD 1 cent, JPY 1/100 yen).
74
71
  * - `'currency'`: the smallest unit the currency stores, 10^-storageDigits major (JPY 1 yen
@@ -99,8 +96,6 @@ export declare function roundMajor(major: number | DecimalText, currency: string
99
96
  digits?: 'display' | 'storage';
100
97
  rounding?: RoundingMode;
101
98
  }): number;
102
- //#endregion
103
- //#region src/arithmetic.d.ts
104
99
  /** An exact ratio of integers (`{ numerator: 1, denominator: 3 }`). */
105
100
  interface Ratio {
106
101
  readonly numerator: number | bigint;
@@ -145,12 +140,8 @@ export declare function within(a: Money, b: Money, tolerance: Money, options?: {
145
140
  }): boolean;
146
141
  /** `d = a - b`; `d` below `tolerance` counts as rounding and gives 0, else `d` (Stripe `refundSyncDelta`). */
147
142
  export declare function excessOver(a: Money, b: Money, tolerance: Money): Money;
148
- //#endregion
149
- //#region src/country.d.ts
150
143
  /** The current legal tender of an ISO 3166 country (`'US'` or `'us'`), or null when unknown. Never guesses USD. */
151
144
  export declare function defaultCurrencyForCountry(country: string): CurrencyCode | null;
152
- //#endregion
153
- //#region src/decimal-text.d.ts
154
145
  /** Anything the family takes as a value. */
155
146
  type DecimalInput = DecimalText | string | number | bigint;
156
147
  /** Canonical DecimalText of `input` (`'4300.00'` gives `'4300'`, `0.1 + 0.2` gives `'0.30000000000000004'`). See `decimalOf` for what is refused. */
@@ -205,8 +196,6 @@ export declare function decimalClamp(a: DecimalText | string, bounds: {
205
196
  export declare function decimalWithin(a: DecimalText | string, b: DecimalText | string, tolerance: DecimalText | string, options?: {
206
197
  inclusive?: boolean;
207
198
  }): boolean;
208
- //#endregion
209
- //#region src/errors.d.ts
210
199
  /**
211
200
  * Why a money operation refused its input:
212
201
  * - `currency_invalid`: not a currency this package knows (or a retired one where only active codes are allowed)
@@ -231,8 +220,6 @@ export declare class MoneyError extends Error {
231
220
  readonly field?: string;
232
221
  constructor(code: MoneyErrorCode, message: string, options?: MoneyErrorOptions);
233
222
  }
234
- //#endregion
235
- //#region src/format.d.ts
236
223
  interface FormatMoneyOptions {
237
224
  /** Default `'en-US'`; an unsupported or malformed tag falls back to it. */
238
225
  locale?: string;
@@ -248,16 +235,26 @@ interface FormatMoneyOptions {
248
235
  signDisplay?: 'auto' | 'always' | 'exceptZero';
249
236
  /** Default `'-'`; `'−'` (U+2212) replaces the leading ASCII minus. */
250
237
  minusSign?: '-' | '−';
238
+ /**
239
+ * How the amount is rounded to the digits shown: `'half-up'` (default) or `'down'` (toward
240
+ * zero), for an upper bound that must not read above itself: a refund cap of HUF 435050
241
+ * (4,350.50) shows `'HUF 4,350'` with `'down'`, never 4,351. `formatStored` rounds a fractional
242
+ * amount to a storage unit the same way first.
243
+ */
244
+ rounding?: DisplayRounding;
251
245
  }
246
+ /** The roundings `formatMoney` and `formatStored` take. */
247
+ type DisplayRounding = Extract<RoundingMode, 'half-up' | 'down'>;
252
248
  /**
253
249
  * Money for people: `'$1,234.50'`, `'¥1,200'`, `'KWD 1.005'`, `'-€5.00'`. Locale, currency
254
- * display, digits and sign are explicit options; the active app locale is the caller's to
255
- * pass. If Intl throws, `'<CODE> <decimal>'`.
250
+ * display, digits, sign and rounding (half-up by default, `'down'` for caps) are explicit
251
+ * options; the active app locale is the caller's to pass. If Intl throws, `'<CODE> <decimal>'`.
256
252
  */
257
253
  export declare function formatMoney(m: Money, options?: FormatMoneyOptions): string;
258
254
  /**
259
255
  * A stored amount that may be fractional (a Medusa total, 107.8175; a percentage promotion) for
260
- * people: rounded half-up to a whole storage unit (`roundToUnit`), then `formatMoney` with `options`.
256
+ * people: rounded to a whole storage unit by `options.rounding` (`roundToUnit`; half-up by default,
257
+ * `'down'` toward zero for a cap), then `formatMoney` with `options`.
261
258
  * A number must be finite; text is plain decimal; an unknown currency throws `currency_invalid`.
262
259
  */
263
260
  export declare function formatStored(amount: number | DecimalText, currency: string, options?: FormatMoneyOptions): string;
@@ -265,7 +262,7 @@ export declare function formatStored(amount: number | DecimalText, currency: str
265
262
  * Like `formatMoney` below `threshold` major units (default 10000, by magnitude); at or above
266
263
  * it, compact short notation with `maximumSignificantDigits` (default 3): `'$12.3K'`.
267
264
  */
268
- export declare function formatMoneyCompact(m: Money, options?: FormatMoneyOptions & {
265
+ export declare function formatMoneyCompact(m: Money, options?: Omit<FormatMoneyOptions, 'rounding'> & {
269
266
  threshold?: number;
270
267
  maximumSignificantDigits?: number;
271
268
  }): string;
@@ -278,8 +275,6 @@ export declare function formatMoneyRange(low: Money, high: Money | null, options
278
275
  * same rounding as `formatMoneyCompact` (`1234567` gives `'$1.23M'`).
279
276
  */
280
277
  export declare function moneyAxisFormatter(currency: string, options?: Pick<FormatMoneyOptions, 'locale' | 'currencyDisplay'>): (major: number) => string;
281
- //#endregion
282
- //#region src/iso-minor.d.ts
283
278
  /**
284
279
  * ISO minor units at the display digits: `round(major x 10^displayDigits)` with `rounding`
285
280
  * (default half-up). JPY 150000 gives 1500, KWD 1005 gives 1005, IQD 10000 gives 10, HUF
@@ -296,5 +291,4 @@ export declare function toIsoMinor(m: Money, options?: {
296
291
  export declare function fromIsoMinor(value: number | string, currency: string, options?: {
297
292
  digits?: FractionDigits;
298
293
  }): Money;
299
- //#endregion
300
- export { type AllocateOptions, type AllocationStrategy, type AllocationWeight, type AmountUnit, CURRENCIES, type CurrencyCode, type CurrencyCodeOptions, type CurrencyInfo, type CurrencyStatus, type DecimalInput, type DecimalText, type FormatMoneyOptions, type FractionDigits, type FractionalMoney, type FromMajorOptions, type MajorDecimal, type MedusaRaw, type Money, type MoneyByCurrency, type MoneyErrorCode, type MoneyErrorOptions, type PriceLike, type Ratio, type ReadStoredDecimalOptions, type ReadStoredOptions, type RoundToUnitOptions, type RoundingMode, type StorageScale, type StoredAmount, type StoredAmountOptions, type ToMajorDecimalOptions, type UnitPricePart, type WaterfallResult, currencyCode, currencyInfo, currencyLabel, currencyName, currencyOptions, currencySymbol, displayDigits, firstCurrency, fromMajor, isCurrencyCode, isPositiveAmount, isStoredAmount, localeForCurrency, medusaCurrencyCode, medusaEpsilon, money, moneyByCurrency, moneyFor, parseCurrencyCode, readCalculatedPrice, readStored, readStoredDecimal, readStoredField, readStoredLiteral, sameCurrency, storageDigits, storageScale, toMajorDecimal, toMajorNumber, toMedusaAmountInput, toMedusaRaw };
294
+ export { type AllocateOptions, type AllocationStrategy, type AllocationWeight, type AmountUnit, CURRENCIES, type CurrencyCode, type CurrencyCodeOptions, type CurrencyInfo, type CurrencyStatus, type DecimalInput, type DecimalText, type DisplayRounding, type FormatMoneyOptions, type FractionDigits, type FractionalMoney, type FromMajorOptions, type MajorDecimal, type MedusaRaw, type Money, type MoneyByCurrency, type MoneyErrorCode, type MoneyErrorOptions, type PriceLike, type Ratio, type ReadStoredDecimalOptions, type ReadStoredOptions, type RoundToUnitOptions, type RoundingMode, type StorageScale, type StoredAmount, type StoredAmountOptions, type ToMajorDecimalOptions, type UnitPricePart, type WaterfallResult, currencyCode, currencyInfo, currencyLabel, currencyName, currencyOptions, currencySymbol, displayDigits, firstCurrency, fromMajor, isCurrencyCode, isPositiveAmount, isStoredAmount, localeForCurrency, medusaCurrencyCode, medusaEpsilon, money, moneyByCurrency, moneyFor, parseCurrencyCode, readCalculatedPrice, readStored, readStoredDecimal, readStoredField, readStoredLiteral, sameCurrency, storageDigits, storageScale, toMajorDecimal, toMajorNumber, toMedusaAmountInput, toMedusaRaw };
package/dist/index.js CHANGED
@@ -1,12 +1,12 @@
1
- import { A as storageScale, C as medusaCurrencyCode, D as sameCurrency, F as decimalClamp, G as isDecimalLiteral, H as decimalSubtract, I as decimalCompare, K as parseDecimalText, L as decimalDivide, O as storageDigits, P as assertDecimalLiteral, Q as MoneyError, R as decimalEquals, S as localeForCurrency, T as parseCurrencyCode, U as decimalSum, V as decimalRound, W as decimalWithin, _ as currencySymbol, a as money, b as firstCurrency, c as toMajorDecimal, d as currencyCode, f as currencyInfo, g as currencyOptions, h as currencyName, l as toMajorNumber, n as fromMajor, o as readStored, p as currencyLabel, q as trimDecimalZeros, r as isStoredAmount, u as CURRENCIES, v as displayDigits, w as medusaEpsilon, x as isCurrencyCode, z as decimalMultiply } from "./money-WhnGiI00.js";
2
- import { i as roundToUnit, n as roundMajor } from "./rounding-g9rvye0k.js";
3
- import { i as splitUnitPrice, r as allocateWaterfall, t as allocate } from "./allocate-X7_jAtOj.js";
4
- import { _ as within, a as equals, c as isPositive, d as min, f as multiply, g as sum, h as subtract, i as divide, l as isZero, m as remaining, n as clamp, o as excessOver, p as percentOf, r as compare, s as isNegative, t as add, u as max } from "./arithmetic-BhNwisjb.js";
5
- import { t as hasOwnKey } from "./own-D7544D3k.js";
6
- import { a as moneyAxisFormatter, i as formatStored, n as formatMoneyCompact, r as formatMoneyRange, t as formatMoney } from "./format-BdPnijvn.js";
7
- import { r as toIsoMinor, t as fromIsoMinor } from "./iso-minor-CqkWDxHS.js";
8
- import { a as readStoredDecimal, i as readCalculatedPrice, l as toMedusaAmountInput, n as moneyByCurrency, o as readStoredField, r as moneyFor, s as readStoredLiteral, t as isPositiveAmount, u as toMedusaRaw } from "./medusa-DqJY1qpj.js";
9
- //#region src/data/countries.ts
1
+ import { A as storageScale, C as medusaCurrencyCode, D as sameCurrency, F as decimalClamp, G as isDecimalLiteral, H as decimalSubtract, I as decimalCompare, K as parseDecimalText, L as decimalDivide, O as storageDigits, P as assertDecimalLiteral, Q as MoneyError, R as decimalEquals, S as localeForCurrency, T as parseCurrencyCode, U as decimalSum, V as decimalRound, W as decimalWithin, _ as currencySymbol, a as money, b as firstCurrency, c as toMajorDecimal, d as currencyCode, f as currencyInfo, g as currencyOptions, h as currencyName, l as toMajorNumber, n as fromMajor, o as readStored, p as currencyLabel, q as trimDecimalZeros, r as isStoredAmount, u as CURRENCIES, v as displayDigits, w as medusaEpsilon, x as isCurrencyCode, z as decimalMultiply } from "./money-BxbAw7BP.js";
2
+ import { i as roundToUnit, n as roundMajor } from "./rounding-CA1PVP3b.js";
3
+ import { i as splitUnitPrice, r as allocateWaterfall, t as allocate } from "./allocate-BBRfdaSC.js";
4
+ import { _ as within, a as equals, c as isPositive, d as min, f as multiply, g as sum, h as subtract, i as divide, l as isZero, m as remaining, n as clamp, o as excessOver, p as percentOf, r as compare, s as isNegative, t as add, u as max } from "./arithmetic-C97-YafD.js";
5
+ import { t as hasOwnKey } from "./own-DHxqIYqL.js";
6
+ import { a as moneyAxisFormatter, i as formatStored, n as formatMoneyCompact, r as formatMoneyRange, t as formatMoney } from "./format-BJC513u4.js";
7
+ import { r as toIsoMinor, t as fromIsoMinor } from "./iso-minor-odkY-e6I.js";
8
+ import { a as readStoredDecimal, i as readCalculatedPrice, l as toMedusaAmountInput, n as moneyByCurrency, o as readStoredField, r as moneyFor, s as readStoredLiteral, t as isPositiveAmount, u as toMedusaRaw } from "./medusa-pKGlImn9.js";
9
+ // src/data/countries.ts
10
10
  const COUNTRY_CURRENCY = {
11
11
  AC: "SHP",
12
12
  AD: "EUR",
@@ -264,13 +264,11 @@ const COUNTRY_CURRENCY = {
264
264
  ZM: "ZMW",
265
265
  ZW: "ZWG"
266
266
  };
267
- //#endregion
268
- //#region src/country.ts
267
+ // src/country.ts
269
268
  /** The current legal tender of an ISO 3166 country (`'US'` or `'us'`), or null when unknown. Never guesses USD. */
270
269
  function defaultCurrencyForCountry(country) {
271
270
  if (typeof country !== "string") return null;
272
271
  const key = country.toUpperCase();
273
272
  return hasOwnKey(COUNTRY_CURRENCY, key) ? COUNTRY_CURRENCY[key] : null;
274
273
  }
275
- //#endregion
276
274
  export { CURRENCIES, MoneyError, add, allocate, allocateWaterfall, assertDecimalLiteral, clamp, compare, currencyCode, currencyInfo, currencyLabel, currencyName, currencyOptions, currencySymbol, decimalClamp, decimalCompare, decimalDivide, decimalEquals, decimalMultiply, decimalRound, decimalSubtract, decimalSum, decimalWithin, defaultCurrencyForCountry, displayDigits, divide, equals, excessOver, firstCurrency, formatMoney, formatMoneyCompact, formatMoneyRange, formatStored, fromIsoMinor, fromMajor, isCurrencyCode, isDecimalLiteral, isNegative, isPositive, isPositiveAmount, isStoredAmount, isZero, localeForCurrency, max, medusaCurrencyCode, medusaEpsilon, min, money, moneyAxisFormatter, moneyByCurrency, moneyFor, multiply, parseCurrencyCode, parseDecimalText, percentOf, readCalculatedPrice, readStored, readStoredDecimal, readStoredField, readStoredLiteral, remaining, roundMajor, roundToUnit, sameCurrency, splitUnitPrice, storageDigits, storageScale, subtract, sum, toIsoMinor, toMajorDecimal, toMajorNumber, toMedusaAmountInput, toMedusaRaw, trimDecimalZeros, within };
package/dist/input.cjs CHANGED
@@ -1,9 +1,9 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_money = require("./money-B3wH_Z4S.cjs");
3
- const require_number_text = require("./number-text-BWu67jUq.cjs");
4
- const require_rate = require("./rate-CVeMii4a.cjs");
5
- const require_amount = require("./amount-BV0O-aN8.cjs");
6
- //#region src/input/import.ts
2
+ const require_money = require("./money-DWBjuuEK.cjs");
3
+ const require_number_text = require("./number-text-CWuVwrlg.cjs");
4
+ const require_rate = require("./rate-CEjWTATc.cjs");
5
+ const require_amount = require("./amount-Bzxw9aD4.cjs");
6
+ // src/input/import.ts
7
7
  /**
8
8
  * Amount text from a file or a third party to canonical DecimalText (major units, exactly as
9
9
  * written: `'1.299,00'` gives `'1299'`), or null when it is not an amount (empty, exponent,
@@ -53,8 +53,7 @@ function parseDecimalInput(text, options) {
53
53
  value: require_money.toDecimalText(value)
54
54
  };
55
55
  }
56
- //#endregion
57
- //#region src/input/percent-rate.ts
56
+ // src/input/percent-rate.ts
58
57
  /**
59
58
  * A typed percent (`'20'`, `'12.5'`, `'12,5 %'` in de-DE) as DecimalText. A `%` before or after
60
59
  * the number is allowed. Default range 0..100 with 2 decimals; below 0 (with a non-negative
@@ -103,8 +102,7 @@ function parseRateInput(text, options = {}) {
103
102
  throw error;
104
103
  }
105
104
  }
106
- //#endregion
107
- //#region src/input/template.ts
105
+ // src/input/template.ts
108
106
  const DEFAULT_TEMPLATE = Object.freeze({
109
107
  prefix: "",
110
108
  suffix: "",
@@ -150,7 +148,6 @@ function formatWithTemplate(m, template) {
150
148
  const tail = fraction === void 0 ? "" : `${template.decimalSeparator}${fraction}`;
151
149
  return `${template.prefix}${negative ? "-" : ""}${grouped}${tail}${template.suffix}`;
152
150
  }
153
- //#endregion
154
151
  exports.formatAmountInput = require_amount.formatAmountInput;
155
152
  exports.formatWithTemplate = formatWithTemplate;
156
153
  exports.inputPlaceholder = require_amount.inputPlaceholder;