@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.
- package/README.md +22 -11
- package/dist/ai.cjs +12 -13
- package/dist/ai.d.cts +5 -9
- package/dist/ai.d.ts +5 -9
- package/dist/ai.js +12 -13
- package/dist/{allocate-CZRg4TOP.cjs → allocate-AusholrC.cjs} +3 -4
- package/dist/{allocate-X7_jAtOj.js → allocate-BBRfdaSC.js} +3 -4
- package/dist/{amount-BV0O-aN8.cjs → amount-Bzxw9aD4.cjs} +32 -14
- package/dist/{amount-BoYBMgK9.js → amount-off8IMBJ.js} +32 -14
- package/dist/{arithmetic-BhNwisjb.js → arithmetic-C97-YafD.js} +4 -5
- package/dist/{arithmetic-DjT4Kzgt.cjs → arithmetic-D8A6IeZ0.cjs} +4 -5
- package/dist/billing.cjs +5 -8
- package/dist/billing.d.cts +1 -9
- package/dist/billing.d.ts +1 -9
- package/dist/billing.js +5 -8
- package/dist/commerce.cjs +15 -23
- package/dist/commerce.d.cts +2 -16
- package/dist/commerce.d.ts +2 -16
- package/dist/commerce.js +15 -23
- package/dist/{format-DLhno7eX.cjs → format-92fzvTXY.cjs} +9 -9
- package/dist/{format-BdPnijvn.js → format-BJC513u4.js} +9 -9
- package/dist/fx.cjs +12 -18
- package/dist/fx.d.cts +5 -15
- package/dist/fx.d.ts +5 -15
- package/dist/fx.js +12 -18
- package/dist/index.cjs +10 -12
- package/dist/index.d.cts +17 -23
- package/dist/index.d.ts +17 -23
- package/dist/index.js +10 -12
- package/dist/input.cjs +7 -10
- package/dist/input.d.cts +16 -22
- package/dist/input.d.ts +16 -22
- package/dist/input.js +7 -10
- package/dist/{iso-minor-wSwJN57T.cjs → iso-minor-DyNjT9A1.cjs} +2 -3
- package/dist/{iso-minor-CqkWDxHS.js → iso-minor-odkY-e6I.js} +2 -3
- package/dist/{medusa-lRY9xlsf.cjs → medusa-CzVK0bth.cjs} +3 -4
- package/dist/{medusa-DBXJXXvF.d.ts → medusa-DofdvIgQ.d.cts} +1 -3
- package/dist/{medusa-4K8N1pUc.d.cts → medusa-DrbYmD2Y.d.ts} +1 -3
- package/dist/{medusa-DqJY1qpj.js → medusa-pKGlImn9.js} +3 -4
- package/dist/{money-B-3aFjNJ.d.cts → money-BkMeYDEW.d.cts} +0 -6
- package/dist/{money-B-3aFjNJ.d.ts → money-BkMeYDEW.d.ts} +0 -6
- package/dist/{money-WhnGiI00.js → money-BxbAw7BP.js} +7 -15
- package/dist/{money-B3wH_Z4S.cjs → money-DWBjuuEK.cjs} +7 -15
- package/dist/{number-text-DE-q4jO5.js → number-text-Bj-gZXiF.js} +3 -4
- package/dist/{number-text-BWu67jUq.cjs → number-text-CWuVwrlg.cjs} +3 -4
- package/dist/{own-oP9DXFWv.cjs → own-C5imDkyB.cjs} +1 -2
- package/dist/{own-D7544D3k.js → own-DHxqIYqL.js} +1 -2
- package/dist/{percent-D1VB9xXG.js → percent-CB3Ixjc_.js} +2 -3
- package/dist/{percent-C0InC2t2.cjs → percent-DABHiSBs.cjs} +2 -3
- package/dist/{rate-DBPiYgT1.d.ts → rate-BvvZUdSu.d.ts} +1 -3
- package/dist/{rate-tqK8ijG0.d.cts → rate-CEakW3ia.d.cts} +1 -3
- package/dist/{rate-CVeMii4a.cjs → rate-CEjWTATc.cjs} +3 -4
- package/dist/{rate-DicStBue.js → rate-D6S2_wgZ.js} +3 -4
- package/dist/{reporting-tpGJbqYp.d.ts → reporting-DFNyDBdi.d.cts} +2 -4
- package/dist/{reporting-CG-ai2sM.d.cts → reporting-jIBILvnr.d.ts} +2 -4
- package/dist/{retail-DRUTTQoJ.d.ts → retail-B04CjW3b.d.ts} +1 -3
- package/dist/{retail-Cml8YSKg.cjs → retail-CYGPU4ea.cjs} +4 -5
- package/dist/{retail-C_BPLvMj.d.cts → retail-CmEyJQOH.d.cts} +1 -3
- package/dist/{retail-1mu888J1.js → retail-DXgs11ov.js} +4 -5
- package/dist/{rounding-DHBtNCHG.cjs → rounding-4QKTRbMQ.cjs} +2 -3
- package/dist/{rounding-g9rvye0k.js → rounding-CA1PVP3b.js} +2 -3
- package/dist/sql.cjs +9 -15
- package/dist/sql.d.cts +2 -12
- package/dist/sql.d.ts +2 -12
- package/dist/sql.js +9 -15
- package/dist/testing.cjs +39198 -12
- package/dist/testing.d.cts +20 -13
- package/dist/testing.d.ts +20 -13
- package/dist/testing.js +39198 -13
- package/dist/{wire-sW0yzqth.js → wire-B4QU8O3W.js} +350 -93
- package/dist/{wire-CaUN9Vf_.d.ts → wire-CVNicirK.d.ts} +165 -46
- package/dist/{wire-xjYXv4go.d.cts → wire-CtNJmWVP.d.cts} +165 -46
- package/dist/{wire-Bhuut8cW.cjs → wire-u2tmHY0Y.cjs} +403 -92
- package/dist/wire.cjs +10 -1
- package/dist/wire.d.cts +2 -2
- package/dist/wire.d.ts +2 -2
- package/dist/wire.js +1 -2
- package/package.json +4 -3
package/dist/input.d.cts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { R as DecimalText, b as FractionDigits, i as Money } from "./money-
|
|
2
|
-
import { r as Rate } from "./rate-
|
|
3
|
-
//#region src/input/amount.d.ts
|
|
1
|
+
import { R as DecimalText, b as FractionDigits, i as Money } from "./money-BkMeYDEW.cjs";
|
|
2
|
+
import { r as Rate } from "./rate-CEakW3ia.cjs";
|
|
4
3
|
/** Why typed text is not an acceptable amount. */
|
|
5
4
|
type ParseFailureReason = 'empty' | 'unparseable' | 'too_many_decimals' | 'negative' | 'zero' | 'below_min' | 'above_max';
|
|
6
5
|
interface ParseAmountInputOptions {
|
|
@@ -15,11 +14,11 @@ interface ParseAmountInputOptions {
|
|
|
15
14
|
/**
|
|
16
15
|
* `'.'`: machine decimal text, the value of an `<input type="number">` (browsers always
|
|
17
16
|
* serialise it with a `.` decimal and no grouping). `.` is the decimal (`'.5'` is 0.5), `,`
|
|
18
|
-
* and any grouping are `'unparseable'
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
* use it; not with `locale`.
|
|
17
|
+
* and any grouping are `'unparseable'`. More fraction digits than the currency stores are
|
|
18
|
+
* `'too_many_decimals'`, never rounded, in every currency: a currency storing 0 digits
|
|
19
|
+
* refuses any fraction (`'1.5'`, `'1.234'` and `'1200.5'` JPY), while trailing zeros carry no
|
|
20
|
+
* extra precision and read as whole (`'1.0'` and `'1.00'` JPY are 1). TND and IQD `'1.500'`
|
|
21
|
+
* are 1.5. Every number input must use it; not with `locale`.
|
|
23
22
|
*/
|
|
24
23
|
decimalSeparator?: '.';
|
|
25
24
|
/** Default false: a leading `-` gives `'negative'`. */
|
|
@@ -58,17 +57,19 @@ type ParseAmountResult = {
|
|
|
58
57
|
* against `,` (see `parseImportAmount`): `'29,99'` EUR is 29.99, `'1.299,00'` and `'1,299'`
|
|
59
58
|
* are 1299, KWD `'1,5'` is 1.5; a currency storing 0 digits rounds a fraction half-up to a
|
|
60
59
|
* whole unit (`'1200.5'` JPY is 1201).
|
|
61
|
-
* - With `locale`: its decimal separator is the decimal and its group separator is valid
|
|
62
|
-
* 3-digit (or Indian lakh) groups
|
|
63
|
-
* before exactly three digits
|
|
64
|
-
*
|
|
65
|
-
*
|
|
60
|
+
* - With `locale`: its decimal separator is always the decimal and its group separator is valid
|
|
61
|
+
* only in 3-digit (or Indian lakh) groups. In a currency that stores no fraction (JPY, VND) the
|
|
62
|
+
* decimal separator before exactly three digits is ambiguous (en-US `'1.234'` JPY could be
|
|
63
|
+
* 1,234 or 1.234) and is `'too_many_decimals'`, never read as grouping; grouping takes the
|
|
64
|
+
* locale's group separator (`'1,234'` en-US, `'1.234'` de-DE). en-US `'29,99'` USD is
|
|
65
|
+
* `'unparseable'`; de-DE `'29,99'` EUR is 29.99; en-US `'1200.5'` JPY is `'too_many_decimals'`.
|
|
66
66
|
* - With `decimalSeparator: '.'` (every `<input type="number">`): `.` is the decimal, nothing
|
|
67
67
|
* groups (`'1,299'` is `'unparseable'`), TND and IQD `'1.500'` are 1.5, and a currency storing
|
|
68
|
-
* 0 digits
|
|
68
|
+
* 0 digits refuses any fraction as `'too_many_decimals'` (`'1.5'` JPY), never rounded;
|
|
69
|
+
* trailing zeros read as whole (`'1.0'` JPY is 1).
|
|
69
70
|
* Otherwise more fraction digits than the currency stores is `'too_many_decimals'`, never rounded
|
|
70
71
|
* (`'1,2345'` USD). Text equal to `original` returns it unchanged (JPY 120050 shown as
|
|
71
|
-
* `'1200.50'`). An unknown currency, or an `original` in another currency, throws.
|
|
72
|
+
* `'1200.50'`), except the ambiguous zero-digit text above. An unknown currency, or an `original` in another currency, throws.
|
|
72
73
|
*/
|
|
73
74
|
export declare function parseAmountInput(text: string, currency: string, options?: ParseAmountInputOptions): ParseAmountResult;
|
|
74
75
|
/**
|
|
@@ -99,8 +100,6 @@ export declare function formatAmountInput(m: Money, options?: {
|
|
|
99
100
|
export declare function inputStep(currency: string): '1' | '0.01' | '0.001';
|
|
100
101
|
/** The placeholder of a money input: `'0'`, `'0.00'` or `'0.000'`, from the storage digits. */
|
|
101
102
|
export declare function inputPlaceholder(currency: string): '0' | '0.00' | '0.000';
|
|
102
|
-
//#endregion
|
|
103
|
-
//#region src/input/import.d.ts
|
|
104
103
|
interface ImportAmountOptions {
|
|
105
104
|
/**
|
|
106
105
|
* `'auto'` (default): spaces, NBSP, thin spaces and apostrophes are grouping, and the
|
|
@@ -142,8 +141,6 @@ export declare function parseDecimalInput(text: string, options: DecimalInputOpt
|
|
|
142
141
|
ok: false;
|
|
143
142
|
reason: ParseFailureReason;
|
|
144
143
|
};
|
|
145
|
-
//#endregion
|
|
146
|
-
//#region src/input/percent-rate.d.ts
|
|
147
144
|
interface PercentInputOptions {
|
|
148
145
|
/** Inclusive, default 0. */
|
|
149
146
|
min?: number;
|
|
@@ -174,8 +171,6 @@ export declare function parsePercentInput(text: string, options?: PercentInputOp
|
|
|
174
171
|
export declare function parseRateInput(text: string, options?: {
|
|
175
172
|
locale?: string;
|
|
176
173
|
}): Rate | null;
|
|
177
|
-
//#endregion
|
|
178
|
-
//#region src/input/template.d.ts
|
|
179
174
|
interface MoneyTemplate {
|
|
180
175
|
/** Text before the number (`'Rp '`, `'€'`), the sign goes after it. */
|
|
181
176
|
readonly prefix: string;
|
|
@@ -199,5 +194,4 @@ export declare function moneyTemplateOf(sample: string): MoneyTemplate;
|
|
|
199
194
|
* (`moneyTemplateOf('Rp 199.000')` prints IDR 2500050 as `'Rp 25.001'`).
|
|
200
195
|
*/
|
|
201
196
|
export declare function formatWithTemplate(m: Money, template: MoneyTemplate): string;
|
|
202
|
-
//#endregion
|
|
203
197
|
export type { DecimalInputOptions, ImportAmountOptions, MoneyTemplate, ParseAmountInputOptions, ParseAmountResult, ParseFailureReason, PercentInputOptions };
|
package/dist/input.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { R as DecimalText, b as FractionDigits, i as Money } from "./money-
|
|
2
|
-
import { r as Rate } from "./rate-
|
|
3
|
-
//#region src/input/amount.d.ts
|
|
1
|
+
import { R as DecimalText, b as FractionDigits, i as Money } from "./money-BkMeYDEW.js";
|
|
2
|
+
import { r as Rate } from "./rate-BvvZUdSu.js";
|
|
4
3
|
/** Why typed text is not an acceptable amount. */
|
|
5
4
|
type ParseFailureReason = 'empty' | 'unparseable' | 'too_many_decimals' | 'negative' | 'zero' | 'below_min' | 'above_max';
|
|
6
5
|
interface ParseAmountInputOptions {
|
|
@@ -15,11 +14,11 @@ interface ParseAmountInputOptions {
|
|
|
15
14
|
/**
|
|
16
15
|
* `'.'`: machine decimal text, the value of an `<input type="number">` (browsers always
|
|
17
16
|
* serialise it with a `.` decimal and no grouping). `.` is the decimal (`'.5'` is 0.5), `,`
|
|
18
|
-
* and any grouping are `'unparseable'
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
* use it; not with `locale`.
|
|
17
|
+
* and any grouping are `'unparseable'`. More fraction digits than the currency stores are
|
|
18
|
+
* `'too_many_decimals'`, never rounded, in every currency: a currency storing 0 digits
|
|
19
|
+
* refuses any fraction (`'1.5'`, `'1.234'` and `'1200.5'` JPY), while trailing zeros carry no
|
|
20
|
+
* extra precision and read as whole (`'1.0'` and `'1.00'` JPY are 1). TND and IQD `'1.500'`
|
|
21
|
+
* are 1.5. Every number input must use it; not with `locale`.
|
|
23
22
|
*/
|
|
24
23
|
decimalSeparator?: '.';
|
|
25
24
|
/** Default false: a leading `-` gives `'negative'`. */
|
|
@@ -58,17 +57,19 @@ type ParseAmountResult = {
|
|
|
58
57
|
* against `,` (see `parseImportAmount`): `'29,99'` EUR is 29.99, `'1.299,00'` and `'1,299'`
|
|
59
58
|
* are 1299, KWD `'1,5'` is 1.5; a currency storing 0 digits rounds a fraction half-up to a
|
|
60
59
|
* whole unit (`'1200.5'` JPY is 1201).
|
|
61
|
-
* - With `locale`: its decimal separator is the decimal and its group separator is valid
|
|
62
|
-
* 3-digit (or Indian lakh) groups
|
|
63
|
-
* before exactly three digits
|
|
64
|
-
*
|
|
65
|
-
*
|
|
60
|
+
* - With `locale`: its decimal separator is always the decimal and its group separator is valid
|
|
61
|
+
* only in 3-digit (or Indian lakh) groups. In a currency that stores no fraction (JPY, VND) the
|
|
62
|
+
* decimal separator before exactly three digits is ambiguous (en-US `'1.234'` JPY could be
|
|
63
|
+
* 1,234 or 1.234) and is `'too_many_decimals'`, never read as grouping; grouping takes the
|
|
64
|
+
* locale's group separator (`'1,234'` en-US, `'1.234'` de-DE). en-US `'29,99'` USD is
|
|
65
|
+
* `'unparseable'`; de-DE `'29,99'` EUR is 29.99; en-US `'1200.5'` JPY is `'too_many_decimals'`.
|
|
66
66
|
* - With `decimalSeparator: '.'` (every `<input type="number">`): `.` is the decimal, nothing
|
|
67
67
|
* groups (`'1,299'` is `'unparseable'`), TND and IQD `'1.500'` are 1.5, and a currency storing
|
|
68
|
-
* 0 digits
|
|
68
|
+
* 0 digits refuses any fraction as `'too_many_decimals'` (`'1.5'` JPY), never rounded;
|
|
69
|
+
* trailing zeros read as whole (`'1.0'` JPY is 1).
|
|
69
70
|
* Otherwise more fraction digits than the currency stores is `'too_many_decimals'`, never rounded
|
|
70
71
|
* (`'1,2345'` USD). Text equal to `original` returns it unchanged (JPY 120050 shown as
|
|
71
|
-
* `'1200.50'`). An unknown currency, or an `original` in another currency, throws.
|
|
72
|
+
* `'1200.50'`), except the ambiguous zero-digit text above. An unknown currency, or an `original` in another currency, throws.
|
|
72
73
|
*/
|
|
73
74
|
export declare function parseAmountInput(text: string, currency: string, options?: ParseAmountInputOptions): ParseAmountResult;
|
|
74
75
|
/**
|
|
@@ -99,8 +100,6 @@ export declare function formatAmountInput(m: Money, options?: {
|
|
|
99
100
|
export declare function inputStep(currency: string): '1' | '0.01' | '0.001';
|
|
100
101
|
/** The placeholder of a money input: `'0'`, `'0.00'` or `'0.000'`, from the storage digits. */
|
|
101
102
|
export declare function inputPlaceholder(currency: string): '0' | '0.00' | '0.000';
|
|
102
|
-
//#endregion
|
|
103
|
-
//#region src/input/import.d.ts
|
|
104
103
|
interface ImportAmountOptions {
|
|
105
104
|
/**
|
|
106
105
|
* `'auto'` (default): spaces, NBSP, thin spaces and apostrophes are grouping, and the
|
|
@@ -142,8 +141,6 @@ export declare function parseDecimalInput(text: string, options: DecimalInputOpt
|
|
|
142
141
|
ok: false;
|
|
143
142
|
reason: ParseFailureReason;
|
|
144
143
|
};
|
|
145
|
-
//#endregion
|
|
146
|
-
//#region src/input/percent-rate.d.ts
|
|
147
144
|
interface PercentInputOptions {
|
|
148
145
|
/** Inclusive, default 0. */
|
|
149
146
|
min?: number;
|
|
@@ -174,8 +171,6 @@ export declare function parsePercentInput(text: string, options?: PercentInputOp
|
|
|
174
171
|
export declare function parseRateInput(text: string, options?: {
|
|
175
172
|
locale?: string;
|
|
176
173
|
}): Rate | null;
|
|
177
|
-
//#endregion
|
|
178
|
-
//#region src/input/template.d.ts
|
|
179
174
|
interface MoneyTemplate {
|
|
180
175
|
/** Text before the number (`'Rp '`, `'€'`), the sign goes after it. */
|
|
181
176
|
readonly prefix: string;
|
|
@@ -199,5 +194,4 @@ export declare function moneyTemplateOf(sample: string): MoneyTemplate;
|
|
|
199
194
|
* (`moneyTemplateOf('Rp 199.000')` prints IDR 2500050 as `'Rp 25.001'`).
|
|
200
195
|
*/
|
|
201
196
|
export declare function formatWithTemplate(m: Money, template: MoneyTemplate): string;
|
|
202
|
-
//#endregion
|
|
203
197
|
export type { DecimalInputOptions, ImportAmountOptions, MoneyTemplate, ParseAmountInputOptions, ParseAmountResult, ParseFailureReason, PercentInputOptions };
|
package/dist/input.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { B as decimalOf, Q as MoneyError, at as fractionDigitsOf, dt as roundToScale, it as formatDecimal, pt as toDecimalText, s as storedDecimal, tt as compareDecimal } from "./money-
|
|
2
|
-
import { n as readNumberText } from "./number-text-
|
|
3
|
-
import { c as rateFromDecimal, o as rate } from "./rate-
|
|
4
|
-
import { a as inputStep, i as inputPlaceholder, n as formatAmountInput, o as localeSeparators, r as groupDigits, s as parseAmountInput, t as decimalOfText } from "./amount-
|
|
5
|
-
|
|
1
|
+
import { B as decimalOf, Q as MoneyError, at as fractionDigitsOf, dt as roundToScale, it as formatDecimal, pt as toDecimalText, s as storedDecimal, tt as compareDecimal } from "./money-BxbAw7BP.js";
|
|
2
|
+
import { n as readNumberText } from "./number-text-Bj-gZXiF.js";
|
|
3
|
+
import { c as rateFromDecimal, o as rate } from "./rate-D6S2_wgZ.js";
|
|
4
|
+
import { a as inputStep, i as inputPlaceholder, n as formatAmountInput, o as localeSeparators, r as groupDigits, s as parseAmountInput, t as decimalOfText } from "./amount-off8IMBJ.js";
|
|
5
|
+
// src/input/import.ts
|
|
6
6
|
/**
|
|
7
7
|
* Amount text from a file or a third party to canonical DecimalText (major units, exactly as
|
|
8
8
|
* written: `'1.299,00'` gives `'1299'`), or null when it is not an amount (empty, exponent,
|
|
@@ -52,8 +52,7 @@ function parseDecimalInput(text, options) {
|
|
|
52
52
|
value: toDecimalText(value)
|
|
53
53
|
};
|
|
54
54
|
}
|
|
55
|
-
|
|
56
|
-
//#region src/input/percent-rate.ts
|
|
55
|
+
// src/input/percent-rate.ts
|
|
57
56
|
/**
|
|
58
57
|
* A typed percent (`'20'`, `'12.5'`, `'12,5 %'` in de-DE) as DecimalText. A `%` before or after
|
|
59
58
|
* the number is allowed. Default range 0..100 with 2 decimals; below 0 (with a non-negative
|
|
@@ -102,8 +101,7 @@ function parseRateInput(text, options = {}) {
|
|
|
102
101
|
throw error;
|
|
103
102
|
}
|
|
104
103
|
}
|
|
105
|
-
|
|
106
|
-
//#region src/input/template.ts
|
|
104
|
+
// src/input/template.ts
|
|
107
105
|
const DEFAULT_TEMPLATE = Object.freeze({
|
|
108
106
|
prefix: "",
|
|
109
107
|
suffix: "",
|
|
@@ -149,5 +147,4 @@ function formatWithTemplate(m, template) {
|
|
|
149
147
|
const tail = fraction === void 0 ? "" : `${template.decimalSeparator}${fraction}`;
|
|
150
148
|
return `${template.prefix}${negative ? "-" : ""}${grouped}${tail}${template.suffix}`;
|
|
151
149
|
}
|
|
152
|
-
//#endregion
|
|
153
150
|
export { formatAmountInput, formatWithTemplate, inputPlaceholder, inputStep, moneyTemplateOf, parseAmountInput, parseDecimalInput, parseImportAmount, parsePercentInput, parseRateInput };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const require_money = require("./money-
|
|
2
|
-
|
|
1
|
+
const require_money = require("./money-DWBjuuEK.cjs");
|
|
2
|
+
// src/iso-minor.ts
|
|
3
3
|
/**
|
|
4
4
|
* Internal: stored units per ISO minor unit at `digits`, `storageScale / 10^digits` (100 for
|
|
5
5
|
* a zero-digit count on a x100 currency, 1 when the digits match the storage exponent).
|
|
@@ -44,7 +44,6 @@ function fromIsoMinor(value, currency, options = {}) {
|
|
|
44
44
|
if (BigInt(integer) % excess !== 0n) throw new require_money.MoneyError("precision", `${integer} at ${digits} digits is not a whole ${info.code} storage unit`);
|
|
45
45
|
return require_money.boundedMoney(BigInt(integer) / excess, info);
|
|
46
46
|
}
|
|
47
|
-
//#endregion
|
|
48
47
|
Object.defineProperty(exports, "fromIsoMinor", {
|
|
49
48
|
enumerable: true,
|
|
50
49
|
get: function() {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { $ as describeValue, E as resolveCurrency, Q as MoneyError, X as mulDiv, k as storageExponent, lt as parseDecimal, s as storedDecimal, t as boundedMoney, ut as pow10 } from "./money-
|
|
2
|
-
|
|
1
|
+
import { $ as describeValue, E as resolveCurrency, Q as MoneyError, X as mulDiv, k as storageExponent, lt as parseDecimal, s as storedDecimal, t as boundedMoney, ut as pow10 } from "./money-BxbAw7BP.js";
|
|
2
|
+
// src/iso-minor.ts
|
|
3
3
|
/**
|
|
4
4
|
* Internal: stored units per ISO minor unit at `digits`, `storageScale / 10^digits` (100 for
|
|
5
5
|
* a zero-digit count on a x100 currency, 1 when the digits match the storage exponent).
|
|
@@ -44,5 +44,4 @@ function fromIsoMinor(value, currency, options = {}) {
|
|
|
44
44
|
if (BigInt(integer) % excess !== 0n) throw new MoneyError("precision", `${integer} at ${digits} digits is not a whole ${info.code} storage unit`);
|
|
45
45
|
return boundedMoney(BigInt(integer) / excess, info);
|
|
46
46
|
}
|
|
47
|
-
//#endregion
|
|
48
47
|
export { isoMinorFactor as n, toIsoMinor as r, fromIsoMinor as t };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
const require_money = require("./money-
|
|
2
|
-
const require_own = require("./own-
|
|
3
|
-
|
|
1
|
+
const require_money = require("./money-DWBjuuEK.cjs");
|
|
2
|
+
const require_own = require("./own-C5imDkyB.cjs");
|
|
3
|
+
// src/medusa.ts
|
|
4
4
|
const isObject = (value) => typeof value === "object" && value !== null;
|
|
5
5
|
/** Internal: `row['raw_' + key]` when it is not null/undefined, else `row[key]` (undefined for a non-object row). */
|
|
6
6
|
function storedFieldValue(row, key) {
|
|
@@ -112,7 +112,6 @@ function isPositiveAmount(raw) {
|
|
|
112
112
|
const value = require_money.medusaAmountDecimal(raw);
|
|
113
113
|
return value !== null && require_money.isPositiveDecimal(value);
|
|
114
114
|
}
|
|
115
|
-
//#endregion
|
|
116
115
|
Object.defineProperty(exports, "isPositiveAmount", {
|
|
117
116
|
enumerable: true,
|
|
118
117
|
get: function() {
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { R as DecimalText, a as ReadStoredOptions, i as Money, o as StoredAmount } from "./money-
|
|
2
|
-
//#region src/medusa.d.ts
|
|
1
|
+
import { R as DecimalText, a as ReadStoredOptions, i as Money, o as StoredAmount } from "./money-BkMeYDEW.cjs";
|
|
3
2
|
/**
|
|
4
3
|
* `row['raw_' + key]` when it is not null/undefined (a failure to read it is final: no
|
|
5
4
|
* fallback to the lossy plain key), else `row[key]`, read like `readStored`.
|
|
@@ -83,5 +82,4 @@ interface PriceLike {
|
|
|
83
82
|
declare function moneyFor(source: MoneyByCurrency | readonly PriceLike[], currency: string): Money | null;
|
|
84
83
|
/** Whether unknown Medusa input holds an amount above zero. `''`, null and garbage are false, never a throw. */
|
|
85
84
|
declare function isPositiveAmount(raw: unknown): boolean;
|
|
86
|
-
//#endregion
|
|
87
85
|
export { isPositiveAmount as a, readCalculatedPrice as c, readStoredLiteral as d, toMedusaAmountInput as f, ReadStoredDecimalOptions as i, readStoredDecimal as l, MoneyByCurrency as n, moneyByCurrency as o, toMedusaRaw as p, PriceLike as r, moneyFor as s, MedusaRaw as t, readStoredField as u };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { R as DecimalText, a as ReadStoredOptions, i as Money, o as StoredAmount } from "./money-
|
|
2
|
-
//#region src/medusa.d.ts
|
|
1
|
+
import { R as DecimalText, a as ReadStoredOptions, i as Money, o as StoredAmount } from "./money-BkMeYDEW.js";
|
|
3
2
|
/**
|
|
4
3
|
* `row['raw_' + key]` when it is not null/undefined (a failure to read it is final: no
|
|
5
4
|
* fallback to the lossy plain key), else `row[key]`, read like `readStored`.
|
|
@@ -83,5 +82,4 @@ interface PriceLike {
|
|
|
83
82
|
declare function moneyFor(source: MoneyByCurrency | readonly PriceLike[], currency: string): Money | null;
|
|
84
83
|
/** Whether unknown Medusa input holds an amount above zero. `''`, null and garbage are false, never a throw. */
|
|
85
84
|
declare function isPositiveAmount(raw: unknown): boolean;
|
|
86
|
-
//#endregion
|
|
87
85
|
export { isPositiveAmount as a, readCalculatedPrice as c, readStoredLiteral as d, toMedusaAmountInput as f, ReadStoredDecimalOptions as i, readStoredDecimal as l, MoneyByCurrency as n, moneyByCurrency as o, toMedusaRaw as p, PriceLike as r, moneyFor as s, MedusaRaw as t, readStoredField as u };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { $ as describeValue, B as decimalOf, D as sameCurrency, E as resolveCurrency, G as isDecimalLiteral, Q as MoneyError, a as money, b as firstCurrency, d as currencyCode, ft as strictNumberDecimal, i as medusaAmountDecimal, o as readStored, ot as isPositiveDecimal, pt as toDecimalText, r as isStoredAmount, s as storedDecimal } from "./money-
|
|
2
|
-
import { t as hasOwnKey } from "./own-
|
|
3
|
-
|
|
1
|
+
import { $ as describeValue, B as decimalOf, D as sameCurrency, E as resolveCurrency, G as isDecimalLiteral, Q as MoneyError, a as money, b as firstCurrency, d as currencyCode, ft as strictNumberDecimal, i as medusaAmountDecimal, o as readStored, ot as isPositiveDecimal, pt as toDecimalText, r as isStoredAmount, s as storedDecimal } from "./money-BxbAw7BP.js";
|
|
2
|
+
import { t as hasOwnKey } from "./own-DHxqIYqL.js";
|
|
3
|
+
// src/medusa.ts
|
|
4
4
|
const isObject = (value) => typeof value === "object" && value !== null;
|
|
5
5
|
/** Internal: `row['raw_' + key]` when it is not null/undefined, else `row[key]` (undefined for a non-object row). */
|
|
6
6
|
function storedFieldValue(row, key) {
|
|
@@ -112,5 +112,4 @@ function isPositiveAmount(raw) {
|
|
|
112
112
|
const value = medusaAmountDecimal(raw);
|
|
113
113
|
return value !== null && isPositiveDecimal(value);
|
|
114
114
|
}
|
|
115
|
-
//#endregion
|
|
116
115
|
export { readStoredDecimal as a, storedFieldValue as c, readCalculatedPrice as i, toMedusaAmountInput as l, moneyByCurrency as n, readStoredField as o, moneyFor as r, readStoredLiteral as s, isPositiveAmount as t, toMedusaRaw as u };
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/decimal.d.ts
|
|
2
1
|
/**
|
|
3
2
|
* How a value between two representable amounts is resolved. `half-up` rounds a tie away from zero.
|
|
4
3
|
* `floor-after-tenth` is Shopify's discount truncation: round to a tenth of the unit (half-up), then
|
|
@@ -10,8 +9,6 @@ declare const DECIMAL_TEXT_BRAND: unique symbol;
|
|
|
10
9
|
type DecimalText = string & {
|
|
11
10
|
readonly [DECIMAL_TEXT_BRAND]: true;
|
|
12
11
|
};
|
|
13
|
-
//#endregion
|
|
14
|
-
//#region src/registry.d.ts
|
|
15
12
|
declare const CURRENCY_CODE: unique symbol;
|
|
16
13
|
/** An upper-case code this package knows. Obtain one from `currencyCode` or `isCurrencyCode`. */
|
|
17
14
|
type CurrencyCode = string & {
|
|
@@ -128,8 +125,6 @@ declare function localeForCurrency(code: string): string;
|
|
|
128
125
|
* numbers, as Medusa does, so these sites agree with Medusa's own `payment_status`.
|
|
129
126
|
*/
|
|
130
127
|
declare function medusaEpsilon(code: string): DecimalText;
|
|
131
|
-
//#endregion
|
|
132
|
-
//#region src/money.d.ts
|
|
133
128
|
declare const STORED_AMOUNT: unique symbol;
|
|
134
129
|
declare const MAJOR_DECIMAL: unique symbol;
|
|
135
130
|
/** An amount in Amboras storage units (major x storageScale): a safe integer. */
|
|
@@ -244,5 +239,4 @@ declare function readStored(raw: unknown, currency: string, options?: ReadStored
|
|
|
244
239
|
mode?: 'strict';
|
|
245
240
|
}): Money;
|
|
246
241
|
declare function readStored(raw: unknown, currency: string, options?: ReadStoredOptions): Money | null;
|
|
247
|
-
//#endregion
|
|
248
242
|
export { isCurrencyCode as A, currencyInfo as C, currencySymbol as D, currencyOptions as E, sameCurrency as F, storageDigits as I, storageScale as L, medusaCurrencyCode as M, medusaEpsilon as N, displayDigits as O, parseCurrencyCode as P, DecimalText as R, currencyCode as S, currencyName as T, CurrencyCodeOptions as _, ReadStoredOptions as a, FractionDigits as b, ToMajorDecimalOptions as c, money as d, readStored as f, CurrencyCode as g, CURRENCIES as h, Money as i, localeForCurrency as j, firstCurrency as k, fromMajor as l, toMajorNumber as m, FromMajorOptions as n, StoredAmount as o, toMajorDecimal as p, MajorDecimal as r, StoredAmountOptions as s, FractionalMoney as t, isStoredAmount as u, CurrencyInfo as v, currencyLabel as w, StorageScale as x, CurrencyStatus as y, RoundingMode as z };
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/decimal.d.ts
|
|
2
1
|
/**
|
|
3
2
|
* How a value between two representable amounts is resolved. `half-up` rounds a tie away from zero.
|
|
4
3
|
* `floor-after-tenth` is Shopify's discount truncation: round to a tenth of the unit (half-up), then
|
|
@@ -10,8 +9,6 @@ declare const DECIMAL_TEXT_BRAND: unique symbol;
|
|
|
10
9
|
type DecimalText = string & {
|
|
11
10
|
readonly [DECIMAL_TEXT_BRAND]: true;
|
|
12
11
|
};
|
|
13
|
-
//#endregion
|
|
14
|
-
//#region src/registry.d.ts
|
|
15
12
|
declare const CURRENCY_CODE: unique symbol;
|
|
16
13
|
/** An upper-case code this package knows. Obtain one from `currencyCode` or `isCurrencyCode`. */
|
|
17
14
|
type CurrencyCode = string & {
|
|
@@ -128,8 +125,6 @@ declare function localeForCurrency(code: string): string;
|
|
|
128
125
|
* numbers, as Medusa does, so these sites agree with Medusa's own `payment_status`.
|
|
129
126
|
*/
|
|
130
127
|
declare function medusaEpsilon(code: string): DecimalText;
|
|
131
|
-
//#endregion
|
|
132
|
-
//#region src/money.d.ts
|
|
133
128
|
declare const STORED_AMOUNT: unique symbol;
|
|
134
129
|
declare const MAJOR_DECIMAL: unique symbol;
|
|
135
130
|
/** An amount in Amboras storage units (major x storageScale): a safe integer. */
|
|
@@ -244,5 +239,4 @@ declare function readStored(raw: unknown, currency: string, options?: ReadStored
|
|
|
244
239
|
mode?: 'strict';
|
|
245
240
|
}): Money;
|
|
246
241
|
declare function readStored(raw: unknown, currency: string, options?: ReadStoredOptions): Money | null;
|
|
247
|
-
//#endregion
|
|
248
242
|
export { isCurrencyCode as A, currencyInfo as C, currencySymbol as D, currencyOptions as E, sameCurrency as F, storageDigits as I, storageScale as L, medusaCurrencyCode as M, medusaEpsilon as N, displayDigits as O, parseCurrencyCode as P, DecimalText as R, currencyCode as S, currencyName as T, CurrencyCodeOptions as _, ReadStoredOptions as a, FractionDigits as b, ToMajorDecimalOptions as c, money as d, readStored as f, CurrencyCode as g, CURRENCIES as h, Money as i, localeForCurrency as j, firstCurrency as k, fromMajor as l, toMajorNumber as m, FromMajorOptions as n, StoredAmount as o, toMajorDecimal as p, MajorDecimal as r, StoredAmountOptions as s, FractionalMoney as t, isStoredAmount as u, CurrencyInfo as v, currencyLabel as w, StorageScale as x, CurrencyStatus as y, RoundingMode as z };
|
|
@@ -137,8 +137,7 @@ function withinFloatNoise(major, digits) {
|
|
|
137
137
|
function unitsWithin(d, limit) {
|
|
138
138
|
return (d.units < 0n ? -d.units : d.units) <= limit;
|
|
139
139
|
}
|
|
140
|
-
|
|
141
|
-
//#region src/errors.ts
|
|
140
|
+
// src/errors.ts
|
|
142
141
|
/** The one error this package throws for bad money input. Check `code`, not the message. */
|
|
143
142
|
var MoneyError = class extends Error {
|
|
144
143
|
constructor(code, message, options = {}) {
|
|
@@ -157,8 +156,7 @@ function describeValue(value) {
|
|
|
157
156
|
return Object.prototype.toString.call(value);
|
|
158
157
|
}
|
|
159
158
|
}
|
|
160
|
-
|
|
161
|
-
//#region src/internal/rational.ts
|
|
159
|
+
// src/internal/rational.ts
|
|
162
160
|
/** `a x b / c` rounded by `mode`. `c` must not be zero; its sign is folded into the numerator. */
|
|
163
161
|
function mulDiv(a, b, c, mode) {
|
|
164
162
|
if (c === 0n) throw new RangeError("mulDiv: division by zero");
|
|
@@ -185,8 +183,7 @@ function gcd(a, b) {
|
|
|
185
183
|
while (y !== 0n) [x, y] = [y, x % y];
|
|
186
184
|
return x;
|
|
187
185
|
}
|
|
188
|
-
|
|
189
|
-
//#region src/decimal-text.ts
|
|
186
|
+
// src/decimal-text.ts
|
|
190
187
|
/**
|
|
191
188
|
* Internal: `input` as an exact Decimal. Text must be plain decimal (`'-12.50'`, `'7'`):
|
|
192
189
|
* no blank, whitespace, exponent, hex, `'.5'` or `'1.'` (`parse`). Numbers are taken by
|
|
@@ -308,8 +305,7 @@ function decimalWithin(a, b, tolerance, options = {}) {
|
|
|
308
305
|
}, limit);
|
|
309
306
|
return options.inclusive === false ? gap < 0 : gap <= 0;
|
|
310
307
|
}
|
|
311
|
-
|
|
312
|
-
//#region src/data/currencies.ts
|
|
308
|
+
// src/data/currencies.ts
|
|
313
309
|
const CURRENCY_ROWS = [
|
|
314
310
|
{
|
|
315
311
|
code: "AED",
|
|
@@ -3227,8 +3223,7 @@ const CURRENCY_ROWS = [
|
|
|
3227
3223
|
commaDecimal: false
|
|
3228
3224
|
}
|
|
3229
3225
|
];
|
|
3230
|
-
|
|
3231
|
-
//#region src/internal/intl.ts
|
|
3226
|
+
// src/internal/intl.ts
|
|
3232
3227
|
const DEFAULT_LOCALE = "en-US";
|
|
3233
3228
|
/**
|
|
3234
3229
|
* `locale` when the runtime supports it, else `'en-US'`. Blank, malformed or unsupported
|
|
@@ -3265,8 +3260,7 @@ function separatorsOf(locale) {
|
|
|
3265
3260
|
group: parts.find((p) => p.type === "group")?.value ?? (decimal === "." ? "," : ".")
|
|
3266
3261
|
};
|
|
3267
3262
|
}
|
|
3268
|
-
|
|
3269
|
-
//#region src/registry.ts
|
|
3263
|
+
// src/registry.ts
|
|
3270
3264
|
/** Every currency this package knows, active and historic, sorted by code. */
|
|
3271
3265
|
const CURRENCIES = Object.freeze(CURRENCY_ROWS.map((row) => Object.freeze({
|
|
3272
3266
|
...row,
|
|
@@ -3425,8 +3419,7 @@ function medusaEpsilon(code) {
|
|
|
3425
3419
|
scale: currencyInfo(code).medusaDigits
|
|
3426
3420
|
});
|
|
3427
3421
|
}
|
|
3428
|
-
|
|
3429
|
-
//#region src/money.ts
|
|
3422
|
+
// src/money.ts
|
|
3430
3423
|
const MAX_UNITS = 2n ** 46n;
|
|
3431
3424
|
const anyKnownCurrency = (currency, field) => resolveCurrency(currency, {
|
|
3432
3425
|
allowHistoric: true,
|
|
@@ -3579,5 +3572,4 @@ function readStored(raw, currency, options = {}) {
|
|
|
3579
3572
|
if (options.mode === "lenient") return null;
|
|
3580
3573
|
throw new MoneyError("amount_invalid", `Invalid stored amount: ${describeValue(raw)}`, { field: options.field });
|
|
3581
3574
|
}
|
|
3582
|
-
//#endregion
|
|
3583
3575
|
export { describeValue as $, storageScale as A, decimalOf as B, medusaCurrencyCode as C, sameCurrency as D, resolveCurrency as E, decimalClamp as F, isDecimalLiteral as G, decimalSubtract as H, decimalCompare as I, compareRatio as J, parseDecimalText as K, decimalDivide as L, resolveLocale as M, separatorsOf as N, storageDigits as O, assertDecimalLiteral as P, MoneyError as Q, decimalEquals as R, localeForCurrency as S, parseCurrencyCode as T, decimalSum as U, decimalRound as V, decimalWithin as W, mulDiv as X, gcd as Y, ratioToDecimal as Z, currencySymbol as _, money as a, fractionDigitsOf as at, firstCurrency as b, toMajorDecimal as c, normalizeDecimal as ct, currencyCode as d, roundToScale as dt, addDecimal as et, currencyInfo as f, strictNumberDecimal as ft, currencyOptions as g, currencyName as h, medusaAmountDecimal as i, formatDecimal as it, numberFormat as j, storageExponent as k, toMajorNumber as l, parseDecimal as lt, currencyMarks as m, unitsWithin as mt, fromMajor as n, decimalFromNumber as nt, readStored as o, isPositiveDecimal as ot, currencyLabel as p, toDecimalText as pt, trimDecimalZeros as q, isStoredAmount as r, divRound as rt, storedDecimal as s, multiplyDecimal as st, boundedMoney as t, compareDecimal as tt, CURRENCIES as u, pow10 as ut, displayDigits as v, medusaEpsilon as w, isCurrencyCode as x, findCurrency as y, decimalMultiply as z };
|
|
@@ -137,8 +137,7 @@ function withinFloatNoise(major, digits) {
|
|
|
137
137
|
function unitsWithin(d, limit) {
|
|
138
138
|
return (d.units < 0n ? -d.units : d.units) <= limit;
|
|
139
139
|
}
|
|
140
|
-
|
|
141
|
-
//#region src/errors.ts
|
|
140
|
+
// src/errors.ts
|
|
142
141
|
/** The one error this package throws for bad money input. Check `code`, not the message. */
|
|
143
142
|
var MoneyError = class extends Error {
|
|
144
143
|
constructor(code, message, options = {}) {
|
|
@@ -157,8 +156,7 @@ function describeValue(value) {
|
|
|
157
156
|
return Object.prototype.toString.call(value);
|
|
158
157
|
}
|
|
159
158
|
}
|
|
160
|
-
|
|
161
|
-
//#region src/internal/rational.ts
|
|
159
|
+
// src/internal/rational.ts
|
|
162
160
|
/** `a x b / c` rounded by `mode`. `c` must not be zero; its sign is folded into the numerator. */
|
|
163
161
|
function mulDiv(a, b, c, mode) {
|
|
164
162
|
if (c === 0n) throw new RangeError("mulDiv: division by zero");
|
|
@@ -185,8 +183,7 @@ function gcd(a, b) {
|
|
|
185
183
|
while (y !== 0n) [x, y] = [y, x % y];
|
|
186
184
|
return x;
|
|
187
185
|
}
|
|
188
|
-
|
|
189
|
-
//#region src/decimal-text.ts
|
|
186
|
+
// src/decimal-text.ts
|
|
190
187
|
/**
|
|
191
188
|
* Internal: `input` as an exact Decimal. Text must be plain decimal (`'-12.50'`, `'7'`):
|
|
192
189
|
* no blank, whitespace, exponent, hex, `'.5'` or `'1.'` (`parse`). Numbers are taken by
|
|
@@ -308,8 +305,7 @@ function decimalWithin(a, b, tolerance, options = {}) {
|
|
|
308
305
|
}, limit);
|
|
309
306
|
return options.inclusive === false ? gap < 0 : gap <= 0;
|
|
310
307
|
}
|
|
311
|
-
|
|
312
|
-
//#region src/data/currencies.ts
|
|
308
|
+
// src/data/currencies.ts
|
|
313
309
|
const CURRENCY_ROWS = [
|
|
314
310
|
{
|
|
315
311
|
code: "AED",
|
|
@@ -3227,8 +3223,7 @@ const CURRENCY_ROWS = [
|
|
|
3227
3223
|
commaDecimal: false
|
|
3228
3224
|
}
|
|
3229
3225
|
];
|
|
3230
|
-
|
|
3231
|
-
//#region src/internal/intl.ts
|
|
3226
|
+
// src/internal/intl.ts
|
|
3232
3227
|
const DEFAULT_LOCALE = "en-US";
|
|
3233
3228
|
/**
|
|
3234
3229
|
* `locale` when the runtime supports it, else `'en-US'`. Blank, malformed or unsupported
|
|
@@ -3265,8 +3260,7 @@ function separatorsOf(locale) {
|
|
|
3265
3260
|
group: parts.find((p) => p.type === "group")?.value ?? (decimal === "." ? "," : ".")
|
|
3266
3261
|
};
|
|
3267
3262
|
}
|
|
3268
|
-
|
|
3269
|
-
//#region src/registry.ts
|
|
3263
|
+
// src/registry.ts
|
|
3270
3264
|
/** Every currency this package knows, active and historic, sorted by code. */
|
|
3271
3265
|
const CURRENCIES = Object.freeze(CURRENCY_ROWS.map((row) => Object.freeze({
|
|
3272
3266
|
...row,
|
|
@@ -3425,8 +3419,7 @@ function medusaEpsilon(code) {
|
|
|
3425
3419
|
scale: currencyInfo(code).medusaDigits
|
|
3426
3420
|
});
|
|
3427
3421
|
}
|
|
3428
|
-
|
|
3429
|
-
//#region src/money.ts
|
|
3422
|
+
// src/money.ts
|
|
3430
3423
|
const MAX_UNITS = 2n ** 46n;
|
|
3431
3424
|
const anyKnownCurrency = (currency, field) => resolveCurrency(currency, {
|
|
3432
3425
|
allowHistoric: true,
|
|
@@ -3579,7 +3572,6 @@ function readStored(raw, currency, options = {}) {
|
|
|
3579
3572
|
if (options.mode === "lenient") return null;
|
|
3580
3573
|
throw new MoneyError("amount_invalid", `Invalid stored amount: ${describeValue(raw)}`, { field: options.field });
|
|
3581
3574
|
}
|
|
3582
|
-
//#endregion
|
|
3583
3575
|
Object.defineProperty(exports, "CURRENCIES", {
|
|
3584
3576
|
enumerable: true,
|
|
3585
3577
|
get: function() {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { $ as describeValue, E as resolveCurrency, dt as roundToScale, m as currencyMarks } from "./money-
|
|
2
|
-
|
|
1
|
+
import { $ as describeValue, E as resolveCurrency, dt as roundToScale, m as currencyMarks } from "./money-BxbAw7BP.js";
|
|
2
|
+
// src/internal/number-text.ts
|
|
3
3
|
const MINUS = /^[-−]/;
|
|
4
4
|
const escapeRegExp = (text) => text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
5
5
|
const unparseable = Object.freeze({ reason: "unparseable" });
|
|
@@ -123,12 +123,11 @@ function readNumberText(text, options = {}) {
|
|
|
123
123
|
negative = true;
|
|
124
124
|
rest = rest.slice(1);
|
|
125
125
|
}
|
|
126
|
-
const read = auto ? readAuto(negative, rest, info, options.keepFraction ? null : options.rounding ?? "half-up") : readExplicit(negative, rest, decimal, group, info);
|
|
126
|
+
const read = auto ? readAuto(negative, rest, info, options.keepFraction ? null : options.rounding ?? "half-up") : readExplicit(negative, rest, decimal, group, options.wholeCurrencyGrouping === false ? null : info);
|
|
127
127
|
if ("reason" in read) return read;
|
|
128
128
|
return {
|
|
129
129
|
...read,
|
|
130
130
|
groupMark: groupMarkOf(written, read.decimalMark)
|
|
131
131
|
};
|
|
132
132
|
}
|
|
133
|
-
//#endregion
|
|
134
133
|
export { readNumberText as n, digitGroupingSource as t };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const require_money = require("./money-
|
|
2
|
-
|
|
1
|
+
const require_money = require("./money-DWBjuuEK.cjs");
|
|
2
|
+
// src/internal/number-text.ts
|
|
3
3
|
const MINUS = /^[-−]/;
|
|
4
4
|
const escapeRegExp = (text) => text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
5
5
|
const unparseable = Object.freeze({ reason: "unparseable" });
|
|
@@ -123,14 +123,13 @@ function readNumberText(text, options = {}) {
|
|
|
123
123
|
negative = true;
|
|
124
124
|
rest = rest.slice(1);
|
|
125
125
|
}
|
|
126
|
-
const read = auto ? readAuto(negative, rest, info, options.keepFraction ? null : options.rounding ?? "half-up") : readExplicit(negative, rest, decimal, group, info);
|
|
126
|
+
const read = auto ? readAuto(negative, rest, info, options.keepFraction ? null : options.rounding ?? "half-up") : readExplicit(negative, rest, decimal, group, options.wholeCurrencyGrouping === false ? null : info);
|
|
127
127
|
if ("reason" in read) return read;
|
|
128
128
|
return {
|
|
129
129
|
...read,
|
|
130
130
|
groupMark: groupMarkOf(written, read.decimalMark)
|
|
131
131
|
};
|
|
132
132
|
}
|
|
133
|
-
//#endregion
|
|
134
133
|
Object.defineProperty(exports, "digitGroupingSource", {
|
|
135
134
|
enumerable: true,
|
|
136
135
|
get: function() {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { X as mulDiv, Z as ratioToDecimal, ut as pow10 } from "./money-
|
|
2
|
-
|
|
1
|
+
import { X as mulDiv, Z as ratioToDecimal, ut as pow10 } from "./money-BxbAw7BP.js";
|
|
2
|
+
// src/internal/percent.ts
|
|
3
3
|
/** 100% for a percent written with `scale` fraction digits: the denominator of its units. */
|
|
4
4
|
function hundredPercent(scale) {
|
|
5
5
|
return 100n * pow10(scale);
|
|
@@ -16,5 +16,4 @@ function basisPointsOf(units, bps, mode, denominator = 1n) {
|
|
|
16
16
|
function percentRatio(a, b, digits) {
|
|
17
17
|
return ratioToDecimal(a * 100n, b, digits);
|
|
18
18
|
}
|
|
19
|
-
//#endregion
|
|
20
19
|
export { percentRatio as i, hundredPercent as n, percentOfUnits as r, basisPointsOf as t };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const require_money = require("./money-
|
|
2
|
-
|
|
1
|
+
const require_money = require("./money-DWBjuuEK.cjs");
|
|
2
|
+
// src/internal/percent.ts
|
|
3
3
|
/** 100% for a percent written with `scale` fraction digits: the denominator of its units. */
|
|
4
4
|
function hundredPercent(scale) {
|
|
5
5
|
return 100n * require_money.pow10(scale);
|
|
@@ -16,7 +16,6 @@ function basisPointsOf(units, bps, mode, denominator = 1n) {
|
|
|
16
16
|
function percentRatio(a, b, digits) {
|
|
17
17
|
return require_money.ratioToDecimal(a * 100n, b, digits);
|
|
18
18
|
}
|
|
19
|
-
//#endregion
|
|
20
19
|
Object.defineProperty(exports, "basisPointsOf", {
|
|
21
20
|
enumerable: true,
|
|
22
21
|
get: function() {
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { R as DecimalText } from "./money-
|
|
2
|
-
//#region src/fx/rate.d.ts
|
|
1
|
+
import { R as DecimalText } from "./money-BkMeYDEW.js";
|
|
3
2
|
/** 1 base unit = numerator / denominator quote units, both in major units. Positive integers. */
|
|
4
3
|
interface Rate {
|
|
5
4
|
readonly numerator: bigint;
|
|
@@ -59,5 +58,4 @@ declare function invertRate(r: Rate): Rate;
|
|
|
59
58
|
declare function crossRate(table: Readonly<Record<string, Rate>>, from: string, to: string, base: string): Rate | null;
|
|
60
59
|
/** Same value (cross-multiplied), whatever the parts: 2/4 equals 1/2. */
|
|
61
60
|
declare function rateEquals(a: Rate, b: Rate): boolean;
|
|
62
|
-
//#endregion
|
|
63
61
|
export { RateRow as a, rate as c, rateFromRow as d, rateToDecimal as f, RateFromDecimalOptions as i, rateEquals as l, RATE_REF as n, crossRate as o, rateToNumber as p, Rate as r, invertRate as s, RATE_BOUNDS as t, rateFromDecimal as u };
|