monetra 2.0.0 → 2.2.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 +177 -160
- package/dist/currency/Currency.d.ts +27 -0
- package/dist/currency/index.d.ts +4 -0
- package/dist/currency/iso4217.d.ts +245 -0
- package/dist/currency/precision.d.ts +2 -0
- package/dist/currency/registry.d.ts +22 -0
- package/dist/errors/BaseError.d.ts +22 -0
- package/dist/errors/CurrencyMismatchError.d.ts +12 -0
- package/dist/errors/InsufficientFundsError.d.ts +4 -0
- package/dist/errors/InvalidArgumentError.d.ts +4 -0
- package/dist/errors/InvalidPrecisionError.d.ts +4 -0
- package/dist/errors/OverflowError.d.ts +4 -0
- package/dist/errors/RoundingRequiredError.d.ts +4 -0
- package/dist/errors/index.d.ts +7 -0
- package/dist/financial/compound.d.ts +20 -0
- package/dist/financial/depreciation.d.ts +30 -0
- package/dist/financial/index.d.ts +7 -0
- package/dist/financial/index.js +1323 -0
- package/dist/financial/index.js.map +1 -0
- package/dist/financial/index.mjs +1275 -0
- package/dist/financial/index.mjs.map +1 -0
- package/dist/financial/investment.d.ts +31 -0
- package/dist/financial/leverage.d.ts +66 -0
- package/dist/financial/loan.d.ts +67 -0
- package/dist/financial/rate.d.ts +169 -0
- package/dist/financial/simple.d.ts +60 -0
- package/dist/format/formatter.d.ts +42 -0
- package/dist/format/parser.d.ts +53 -0
- package/dist/index.d.ts +11 -1202
- package/dist/index.js +263 -41
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +248 -41
- package/dist/index.mjs.map +1 -1
- package/dist/ledger/Ledger.d.ts +65 -0
- package/dist/ledger/index.d.ts +3 -0
- package/dist/ledger/index.js +1054 -0
- package/dist/ledger/index.js.map +1 -0
- package/dist/ledger/index.mjs +1029 -0
- package/dist/ledger/index.mjs.map +1 -0
- package/dist/ledger/types.d.ts +30 -0
- package/dist/ledger/verification.d.ts +36 -0
- package/dist/money/Converter.d.ts +26 -0
- package/dist/money/Money.d.ts +299 -0
- package/dist/money/MoneyBag.d.ts +46 -0
- package/dist/money/allocation.d.ts +13 -0
- package/dist/money/arithmetic.d.ts +32 -0
- package/dist/money/guards.d.ts +3 -0
- package/dist/money/index.d.ts +4 -0
- package/dist/rounding/index.d.ts +3 -0
- package/dist/rounding/strategies.d.ts +36 -0
- package/dist/tokens/defineToken.d.ts +30 -0
- package/dist/tokens/index.d.ts +2 -0
- package/dist/tokens/index.js +100 -0
- package/dist/tokens/index.js.map +1 -0
- package/dist/tokens/index.mjs +69 -0
- package/dist/tokens/index.mjs.map +1 -0
- package/dist/tokens/types.d.ts +13 -0
- package/package.json +34 -14
- package/dist/index.d.mts +0 -1211
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { Currency } from "../currency/Currency";
|
|
2
|
+
/**
|
|
3
|
+
* Options for locale-aware parsing.
|
|
4
|
+
*/
|
|
5
|
+
export interface LocaleParseOptions {
|
|
6
|
+
/**
|
|
7
|
+
* The locale to use for parsing (e.g., "en-US", "de-DE").
|
|
8
|
+
* Used to detect decimal and grouping separators.
|
|
9
|
+
*/
|
|
10
|
+
locale: string;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Parses a locale-formatted string into a normalized decimal string.
|
|
14
|
+
*
|
|
15
|
+
* Handles locale-specific decimal separators (e.g., comma in German "1.234,56")
|
|
16
|
+
* and grouping separators (e.g., period in German "1.234").
|
|
17
|
+
*
|
|
18
|
+
* @param amount - The locale-formatted amount string (e.g., "1,234.56" or "1.234,56").
|
|
19
|
+
* @param options - The locale options.
|
|
20
|
+
* @returns A normalized decimal string (e.g., "1234.56").
|
|
21
|
+
* @example
|
|
22
|
+
* parseLocaleString("1.234,56", { locale: "de-DE" }); // "1234.56"
|
|
23
|
+
* parseLocaleString("1,234.56", { locale: "en-US" }); // "1234.56"
|
|
24
|
+
*/
|
|
25
|
+
export declare function parseLocaleString(amount: string, options: LocaleParseOptions): string;
|
|
26
|
+
/**
|
|
27
|
+
* Parses a locale-formatted amount string and converts it to Money minor units.
|
|
28
|
+
*
|
|
29
|
+
* This is a convenience function that combines locale parsing with currency validation.
|
|
30
|
+
*
|
|
31
|
+
* @param amount - The locale-formatted amount string.
|
|
32
|
+
* @param currency - The currency to validate against.
|
|
33
|
+
* @param options - The locale options.
|
|
34
|
+
* @returns The amount in minor units as a BigInt.
|
|
35
|
+
* @throws {InvalidPrecisionError} If the precision exceeds the currency's decimals.
|
|
36
|
+
* @example
|
|
37
|
+
* parseLocaleToMinor("1.234,56", EUR, { locale: "de-DE" }); // 123456n
|
|
38
|
+
*/
|
|
39
|
+
export declare function parseLocaleToMinor(amount: string, currency: Currency, options: LocaleParseOptions): bigint;
|
|
40
|
+
/**
|
|
41
|
+
* Parses a string representation of a major unit amount into minor units.
|
|
42
|
+
*
|
|
43
|
+
* Validates the input format to ensure it is a valid decimal number without
|
|
44
|
+
* scientific notation or ambiguous characters. Checks that the precision
|
|
45
|
+
* does not exceed the currency's allowed decimals.
|
|
46
|
+
*
|
|
47
|
+
* @param amount - The amount string (e.g., "10.50").
|
|
48
|
+
* @param currency - The currency to validate against.
|
|
49
|
+
* @returns The amount in minor units as a BigInt.
|
|
50
|
+
* @throws {Error} If the format is invalid (scientific notation, non-numeric chars).
|
|
51
|
+
* @throws {InvalidPrecisionError} If the precision exceeds the currency's decimals.
|
|
52
|
+
*/
|
|
53
|
+
export declare function parseToMinor(amount: string, currency: Currency): bigint;
|