cldr-region-currency 0.0.0 → 1.0.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/LICENSE ADDED
@@ -0,0 +1,7 @@
1
+ Copyright 2025-Present Aviv Keller
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
+ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,69 @@
1
+ # cldr-region-currency
2
+
3
+ Finds the currency used in a country or region, now or on any date since
4
+ the 1800s, and how amounts in a currency are rounded, using the [Unicode CLDR](https://cldr.unicode.org/) currency
5
+ history.
6
+
7
+ ## Installation
8
+
9
+ ```sh
10
+ npm install cldr-region-currency
11
+ ```
12
+
13
+ ## Usage
14
+
15
+ ```js
16
+ import { getCurrencies, getCurrency } from "cldr-region-currency";
17
+
18
+ getCurrency("US"); // "USD"
19
+ getCurrency("DE"); // "EUR"
20
+ getCurrency("DE", new Date("1990-06-01")); // "DEM"
21
+ getCurrencies("PA"); // ["PAB", "USD"]
22
+
23
+ // With the user's region:
24
+ const { region } = new Intl.Locale(navigator.language).maximize();
25
+ new Intl.NumberFormat(navigator.language, {
26
+ style: "currency",
27
+ currency: getCurrency(region) ?? "USD",
28
+ }).format(9.99);
29
+ ```
30
+
31
+ ## API
32
+
33
+ ### `getCurrency(region, date?)`
34
+
35
+ Returns the ISO 4217 code of the primary legal tender currency of a region
36
+ (an ISO 3166 code such as `"US"`, case-insensitive) on a date (default:
37
+ now), or `undefined` if it has none.
38
+
39
+ ### `getCurrencies(region, date?)`
40
+
41
+ Returns all legal tender currencies of a region on a date, the primary one
42
+ first.
43
+
44
+ ### `getCurrencyRounding(currency)`
45
+
46
+ Returns how amounts in a currency are rounded, as options for
47
+ `Intl.NumberFormat`: `{ fractionDigits, roundingIncrement,
48
+ cashFractionDigits, cashRoundingIncrement }`. Cash amounts can differ: Swiss
49
+ francs are rounded to 0.05, and Swedish kronor to whole kronor.
50
+
51
+ ```js
52
+ const { cashFractionDigits, cashRoundingIncrement } =
53
+ getCurrencyRounding("CHF");
54
+ new Intl.NumberFormat("de-CH", {
55
+ style: "currency",
56
+ currency: "CHF",
57
+ minimumFractionDigits: cashFractionDigits,
58
+ maximumFractionDigits: cashFractionDigits,
59
+ roundingIncrement: cashRoundingIncrement,
60
+ }).format(1.03); // "CHF 1.05"
61
+ ```
62
+
63
+ ### `VERSION`
64
+
65
+ The CLDR version of the data, such as `"49.0.0"`.
66
+
67
+ ## License
68
+
69
+ MIT. Includes data from the Unicode CLDR, © Unicode, Inc., under the [Unicode License v3](https://www.unicode.org/license.txt).
package/index.d.mts ADDED
@@ -0,0 +1,44 @@
1
+ export declare const VERSION: string;
2
+ /**
3
+ * Returns a region's legal tender currencies on a date, primary first
4
+ * @param {string} region - ISO 3166 code
5
+ * @param {Date} [date] - Defaults to now
6
+ * @returns {string[]} ISO 4217 codes
7
+ */
8
+ export declare function getCurrencies(region: string, date?: Date): string[];
9
+ /**
10
+ * Returns the primary currency of a region on a date
11
+ * @param {string} region - ISO 3166 code
12
+ * @param {Date} [date] - Defaults to now
13
+ * @returns {string | undefined} ISO 4217 code
14
+ */
15
+ export declare function getCurrency(region: string, date?: Date): string | undefined;
16
+ /**
17
+ * Returns how a currency is rounded, as Intl.NumberFormat options
18
+ * @param {string} currency - ISO 4217 code
19
+ * @returns {CurrencyRounding}
20
+ */
21
+ export declare function getCurrencyRounding(currency: string): CurrencyRounding;
22
+ declare const _default: {
23
+ getCurrency: typeof getCurrency;
24
+ getCurrencies: typeof getCurrencies;
25
+ getCurrencyRounding: typeof getCurrencyRounding;
26
+ VERSION: string;
27
+ };
28
+ export type CurrencyRounding = {
29
+ fractionDigits: number;
30
+ /**
31
+ * In units of the last decimal place
32
+ */
33
+ roundingIncrement: number;
34
+ cashFractionDigits: number;
35
+ cashRoundingIncrement: number;
36
+ };
37
+ /**
38
+ * @typedef {object} CurrencyRounding
39
+ * @property {number} fractionDigits
40
+ * @property {number} roundingIncrement In units of the last decimal place
41
+ * @property {number} cashFractionDigits
42
+ * @property {number} cashRoundingIncrement
43
+ */
44
+ export { _default as default };
package/index.mjs ADDED
@@ -0,0 +1,2 @@
1
+ /*! cldr-region-currency | MIT License | Includes data © Unicode, Inc., Unicode License v3 (https://www.unicode.org/license.txt) */
2
+ function e(e){if(typeof e!=`string`)throw TypeError(`Input must be a string`)}const t=/* @__PURE__ */ new Map([[`ADP`,[0,1,0,1]],[`AFN`,[0,1,0,1]],[`ALL`,[0,1,0,1]],[`AMD`,[2,1,0,1]],[`BHD`,[3,1,3,1]],[`BIF`,[0,1,0,1]],[`BYR`,[0,1,0,1]],[`CAD`,[2,1,2,5]],[`CHF`,[2,1,2,5]],[`CLF`,[4,1,4,1]],[`CLP`,[0,1,0,1]],[`COP`,[0,1,0,1]],[`CRC`,[2,1,0,1]],[`CZK`,[2,1,0,1]],[`DEFAULT`,[2,1,2,1]],[`DJF`,[0,1,0,1]],[`DKK`,[2,1,2,50]],[`ESP`,[0,1,0,1]],[`GNF`,[0,1,0,1]],[`GYD`,[2,1,0,1]],[`HUF`,[0,1,0,5]],[`IDR`,[0,1,0,1]],[`IQD`,[0,1,0,1]],[`IRR`,[0,1,0,1]],[`ISK`,[0,1,0,1]],[`ITL`,[0,1,0,1]],[`JOD`,[3,1,3,1]],[`JPY`,[0,1,0,1]],[`KMF`,[0,1,0,1]],[`KPW`,[0,1,0,1]],[`KRW`,[0,1,0,1]],[`KWD`,[3,1,3,1]],[`LAK`,[0,1,0,1]],[`LBP`,[0,1,0,1]],[`LUF`,[0,1,0,1]],[`LYD`,[3,1,3,1]],[`MGA`,[0,1,0,1]],[`MGF`,[0,1,0,1]],[`MMK`,[0,1,0,1]],[`MNT`,[2,1,0,1]],[`MRO`,[0,1,0,1]],[`MRU`,[2,1,2,20]],[`MUR`,[2,1,0,1]],[`NOK`,[2,1,0,1]],[`OMR`,[3,1,3,1]],[`PKR`,[2,1,0,1]],[`PYG`,[0,1,0,1]],[`RSD`,[2,1,0,1]],[`RWF`,[0,1,0,1]],[`SEK`,[2,1,0,1]],[`SLL`,[0,1,0,1]],[`SOS`,[0,1,0,1]],[`STD`,[0,1,0,1]],[`SYP`,[0,1,0,1]],[`TMM`,[0,1,0,1]],[`TND`,[3,1,3,1]],[`TRL`,[0,1,0,1]],[`TWD`,[2,1,0,1]],[`TZS`,[2,1,0,1]],[`UGX`,[0,1,0,1]],[`UYI`,[0,1,0,1]],[`UYW`,[4,1,4,1]],[`UZS`,[2,1,0,1]],[`VEF`,[2,1,0,1]],[`VND`,[0,1,0,1]],[`VUV`,[0,1,0,1]],[`XAF`,[0,1,0,1]],[`XOF`,[0,1,0,1]],[`XPF`,[0,1,0,1]],[`YER`,[0,1,0,1]],[`ZMK`,[0,1,0,1]],[`ZWD`,[0,1,0,1]]]),n=/* @__PURE__ */ new Map([[`AC`,[[`SHP`,`1976-01-01`,null]]],[`AD`,[[`EUR`,`1999-01-01`,null],[`ESP`,`1873-01-01`,`2002-02-28`],[`FRF`,`1960-01-01`,`2002-02-17`],[`ADP`,`1936-01-01`,`2001-12-31`]]],[`AE`,[[`AED`,`1973-05-19`,null]]],[`AF`,[[`AFN`,`2002-10-07`,null],[`AFA`,`1927-03-14`,`2002-12-31`]]],[`AG`,[[`XCD`,`1965-10-06`,null]]],[`AI`,[[`XCD`,`1965-10-06`,null]]],[`AL`,[[`ALL`,`1965-08-16`,null],[`ALK`,`1946-11-01`,`1965-08-16`]]],[`AM`,[[`AMD`,`1993-11-22`,null],[`RUR`,`1991-12-25`,`1993-11-22`],[`SUR`,`1961-01-01`,`1991-12-25`]]],[`AO`,[[`AOA`,`1999-12-13`,null],[`AOR`,`1995-07-01`,`2000-02-01`],[`AON`,`1990-09-25`,`2000-02-01`],[`AOK`,`1977-01-08`,`1991-03-01`]]],[`AQ`,[]],[`AR`,[[`ARS`,`1992-01-01`,null],[`ARA`,`1985-06-14`,`1992-01-01`],[`ARP`,`1983-06-01`,`1985-06-14`],[`ARL`,`1970-01-01`,`1983-06-01`],[`ARM`,`1881-11-05`,`1970-01-01`]]],[`AS`,[[`USD`,`1904-07-16`,null]]],[`AT`,[[`EUR`,`1999-01-01`,null],[`ATS`,`1947-12-04`,`2002-02-28`]]],[`AU`,[[`AUD`,`1966-02-14`,null]]],[`AW`,[[`AWG`,`1986-01-01`,null],[`ANG`,`1940-05-10`,`1986-01-01`]]],[`AX`,[[`EUR`,`1999-01-01`,null]]],[`AZ`,[[`AZN`,`2006-01-01`,null],[`AZM`,`1993-11-22`,`2006-12-31`],[`RUR`,`1991-12-25`,`1994-01-01`],[`SUR`,`1961-01-01`,`1991-12-25`]]],[`BA`,[[`BAM`,`1995-01-01`,null],[`BAN`,`1994-08-15`,`1997-07-01`],[`BAD`,`1992-07-01`,`1994-08-15`],[`YUR`,`1992-07-01`,`1993-10-01`],[`YUN`,`1990-01-01`,`1992-07-01`],[`YUD`,`1966-01-01`,`1990-01-01`]]],[`BB`,[[`BBD`,`1973-12-03`,null],[`XCD`,`1965-10-06`,`1973-12-03`]]],[`BD`,[[`BDT`,`1972-01-01`,null],[`PKR`,`1948-04-01`,`1972-01-01`],[`INR`,`1835-08-17`,`1948-04-01`]]],[`BE`,[[`EUR`,`1999-01-01`,null],[`BEF`,`1831-02-07`,`2002-02-28`],[`NLG`,`1816-12-15`,`1831-02-07`]]],[`BF`,[[`XOF`,`1984-08-04`,null]]],[`BG`,[[`EUR`,`2026-01-01`,null],[`BGN`,`1999-07-05`,`2026-01-31`],[`BGL`,`1962-01-01`,`1999-07-05`],[`BGM`,`1952-05-12`,`1962-01-01`],[`BGO`,`1879-07-08`,`1952-05-12`]]],[`BH`,[[`BHD`,`1965-10-16`,null]]],[`BI`,[[`BIF`,`1964-05-19`,null]]],[`BJ`,[[`XOF`,`1975-11-30`,null]]],[`BL`,[[`EUR`,`1999-01-01`,null],[`FRF`,`1960-01-01`,`2002-02-17`]]],[`BM`,[[`BMD`,`1970-02-06`,null]]],[`BN`,[[`BND`,`1967-06-12`,null],[`MYR`,`1963-09-16`,`1967-06-12`]]],[`BO`,[[`BOB`,`1987-01-01`,null],[`BOP`,`1963-01-01`,`1986-12-31`],[`BOL`,`1863-06-23`,`1963-01-01`]]],[`BQ`,[[`USD`,`2011-01-01`,null],[`ANG`,`2010-10-10`,`2011-01-01`]]],[`BR`,[[`BRL`,`1994-07-01`,null],[`BRR`,`1993-08-01`,`1994-07-01`],[`BRE`,`1990-03-16`,`1993-08-01`],[`BRN`,`1989-01-15`,`1990-03-16`],[`BRC`,`1986-02-28`,`1989-01-15`],[`BRB`,`1967-02-13`,`1986-02-28`],[`BRZ`,`1942-11-01`,`1967-02-13`]]],[`BS`,[[`BSD`,`1966-05-25`,null]]],[`BT`,[[`BTN`,`1974-04-16`,null],[`INR`,`1907-01-01`,null]]],[`BU`,[[`BUK`,`1952-07-01`,`1989-06-18`]]],[`BV`,[[`NOK`,`1905-06-07`,null]]],[`BW`,[[`BWP`,`1976-08-23`,null],[`ZAR`,`1961-02-14`,`1976-08-23`]]],[`BY`,[[`BYN`,`2016-07-01`,null],[`BYR`,`2000-01-01`,`2017-01-01`],[`BYB`,`1994-08-01`,`2000-12-31`],[`RUR`,`1991-12-25`,`1994-11-08`],[`SUR`,`1961-01-01`,`1991-12-25`]]],[`BZ`,[[`BZD`,`1974-01-01`,null]]],[`CA`,[[`CAD`,`1858-01-01`,null]]],[`CC`,[[`AUD`,`1966-02-14`,null]]],[`CD`,[[`CDF`,`1998-07-01`,null],[`ZRN`,`1993-11-01`,`1998-07-01`],[`ZRZ`,`1971-10-27`,`1993-11-01`]]],[`CF`,[[`XAF`,`1993-01-01`,null]]],[`CG`,[[`XAF`,`1993-01-01`,null]]],[`CH`,[[`CHF`,`1799-03-17`,null]]],[`CI`,[[`XOF`,`1958-12-04`,null]]],[`CK`,[[`NZD`,`1967-07-10`,null]]],[`CL`,[[`CLP`,`1975-09-29`,null],[`CLE`,`1960-01-01`,`1975-09-29`]]],[`CM`,[[`XAF`,`1973-04-01`,null]]],[`CN`,[[`CNY`,`1953-03-01`,null]]],[`CO`,[[`COP`,`1905-01-01`,null]]],[`CP`,[]],[`CR`,[[`CRC`,`1896-10-26`,null]]],[`CS`,[[`CSD`,`2002-05-15`,`2006-06-03`],[`EUR`,`2003-02-04`,`2006-06-03`],[`YUM`,`1994-01-24`,`2002-05-15`]]],[`CU`,[[`CUP`,`1859-01-01`,null],[`CUC`,`1994-01-01`,`2021-06-01`],[`USD`,`1899-01-01`,`1959-01-01`]]],[`CV`,[[`CVE`,`1914-01-01`,null],[`PTE`,`1911-05-22`,`1975-07-05`]]],[`CW`,[[`XCG`,`2025-03-31`,null],[`ANG`,`2010-10-10`,`2025-06-30`]]],[`CX`,[[`AUD`,`1966-02-14`,null]]],[`CY`,[[`EUR`,`2008-01-01`,null],[`CYP`,`1914-09-10`,`2008-01-31`]]],[`CZ`,[[`CZK`,`1993-01-01`,null],[`CSK`,`1953-06-01`,`1993-03-01`]]],[`DD`,[[`DDM`,`1948-07-20`,`1990-10-02`]]],[`DE`,[[`EUR`,`1999-01-01`,null],[`DEM`,`1948-06-20`,`2002-02-28`]]],[`DG`,[[`USD`,`1965-11-08`,null]]],[`DJ`,[[`DJF`,`1977-06-27`,null]]],[`DK`,[[`DKK`,`1873-05-27`,null]]],[`DM`,[[`XCD`,`1965-10-06`,null]]],[`DO`,[[`DOP`,`1947-10-01`,null],[`USD`,`1905-06-21`,`1947-10-01`]]],[`DZ`,[[`DZD`,`1964-04-01`,null]]],[`EA`,[[`EUR`,`1999-01-01`,null]]],[`EC`,[[`USD`,`2000-10-02`,null],[`ECS`,`1884-04-01`,`2000-10-02`]]],[`EE`,[[`EUR`,`2011-01-01`,null],[`EEK`,`1992-06-21`,`2010-12-31`],[`SUR`,`1961-01-01`,`1992-06-20`]]],[`EG`,[[`EGP`,`1885-11-14`,null]]],[`EH`,[[`MAD`,`1976-02-26`,null]]],[`ER`,[[`ERN`,`1997-11-08`,null],[`ETB`,`1993-05-24`,`1997-11-08`]]],[`ES`,[[`EUR`,`1999-01-01`,null],[`ESP`,`1868-10-19`,`2002-02-28`]]],[`ET`,[[`ETB`,`1976-09-15`,null]]],[`EU`,[[`EUR`,`1999-01-01`,null]]],[`FI`,[[`EUR`,`1999-01-01`,null],[`FIM`,`1963-01-01`,`2002-02-28`]]],[`FJ`,[[`FJD`,`1969-01-13`,null]]],[`FK`,[[`FKP`,`1901-01-01`,null]]],[`FM`,[[`USD`,`1944-01-01`,null],[`JPY`,`1914-10-03`,`1944-01-01`]]],[`FO`,[[`DKK`,`1948-01-01`,null]]],[`FR`,[[`EUR`,`1999-01-01`,null],[`FRF`,`1960-01-01`,`2002-02-17`]]],[`GA`,[[`XAF`,`1993-01-01`,null]]],[`GB`,[[`GBP`,`1694-07-27`,null]]],[`GD`,[[`XCD`,`1967-02-27`,null]]],[`GE`,[[`GEL`,`1995-09-23`,null],[`GEK`,`1993-04-05`,`1995-09-25`],[`RUR`,`1991-12-25`,`1993-06-11`],[`SUR`,`1961-01-01`,`1991-12-25`]]],[`GF`,[[`EUR`,`1999-01-01`,null],[`FRF`,`1960-01-01`,`2002-02-17`]]],[`GG`,[[`GBP`,`1830-01-01`,null]]],[`GH`,[[`GHS`,`2007-07-03`,null],[`GHC`,`1979-03-09`,`2007-12-31`]]],[`GI`,[[`GIP`,`1713-01-01`,null]]],[`GL`,[[`DKK`,`1873-05-27`,null]]],[`GM`,[[`GMD`,`1971-07-01`,null]]],[`GN`,[[`GNF`,`1986-01-06`,null],[`GNS`,`1972-10-02`,`1986-01-06`]]],[`GP`,[[`EUR`,`1999-01-01`,null],[`FRF`,`1960-01-01`,`2002-02-17`]]],[`GQ`,[[`XAF`,`1993-01-01`,null],[`GQE`,`1975-07-07`,`1986-06-01`]]],[`GR`,[[`EUR`,`2001-01-01`,null],[`GRD`,`1954-05-01`,`2002-02-28`]]],[`GS`,[[`GBP`,`1908-01-01`,null]]],[`GT`,[[`GTQ`,`1925-05-27`,null]]],[`GU`,[[`USD`,`1944-08-21`,null]]],[`GW`,[[`XOF`,`1997-03-31`,null],[`GWP`,`1976-02-28`,`1997-03-31`],[`GWE`,`1914-01-01`,`1976-02-28`]]],[`GY`,[[`GYD`,`1966-05-26`,null]]],[`HK`,[[`HKD`,`1895-02-02`,null]]],[`HM`,[[`AUD`,`1967-02-16`,null]]],[`HN`,[[`HNL`,`1926-04-03`,null]]],[`HR`,[[`EUR`,`2023-01-01`,null],[`HRK`,`1994-05-30`,`2023-01-14`],[`HRD`,`1991-12-23`,`1995-01-01`],[`YUN`,`1990-01-01`,`1991-12-23`],[`YUD`,`1966-01-01`,`1990-01-01`]]],[`HT`,[[`HTG`,`1872-08-26`,null],[`USD`,`1915-01-01`,null]]],[`HU`,[[`HUF`,`1946-07-23`,null]]],[`IC`,[[`EUR`,`1999-01-01`,null]]],[`ID`,[[`IDR`,`1965-12-13`,null]]],[`IE`,[[`EUR`,`1999-01-01`,null],[`IEP`,`1922-01-01`,`2002-02-09`],[`GBP`,`1800-01-01`,`1922-01-01`]]],[`IL`,[[`ILS`,`1985-09-04`,null],[`ILR`,`1980-02-22`,`1985-09-04`],[`ILP`,`1948-08-16`,`1980-02-22`]]],[`IM`,[[`GBP`,`1840-01-03`,null]]],[`IN`,[[`INR`,`1835-08-17`,null]]],[`IO`,[[`USD`,`1965-11-08`,null]]],[`IQ`,[[`IQD`,`1931-04-19`,null],[`EGP`,`1920-11-11`,`1931-04-19`],[`INR`,`1920-11-11`,`1931-04-19`]]],[`IR`,[[`IRR`,`1932-05-13`,null]]],[`IS`,[[`ISK`,`1981-01-01`,null],[`ISJ`,`1918-12-01`,`1981-01-01`],[`DKK`,`1873-05-27`,`1918-12-01`]]],[`IT`,[[`EUR`,`1999-01-01`,null],[`ITL`,`1862-08-24`,`2002-02-28`]]],[`JE`,[[`GBP`,`1837-01-01`,null]]],[`JM`,[[`JMD`,`1969-09-08`,null]]],[`JO`,[[`JOD`,`1950-07-01`,null]]],[`JP`,[[`JPY`,`1871-06-01`,null]]],[`KE`,[[`KES`,`1966-09-14`,null]]],[`KG`,[[`KGS`,`1993-05-10`,null],[`RUR`,`1991-12-25`,`1993-05-10`],[`SUR`,`1961-01-01`,`1991-12-25`]]],[`KH`,[[`KHR`,`1980-03-20`,null]]],[`KI`,[[`AUD`,`1966-02-14`,null]]],[`KM`,[[`KMF`,`1975-07-06`,null]]],[`KN`,[[`XCD`,`1965-10-06`,null]]],[`KP`,[[`KPW`,`1959-04-17`,null]]],[`KR`,[[`KRW`,`1962-06-10`,null],[`KRH`,`1953-02-15`,`1962-06-10`],[`KRO`,`1945-08-15`,`1953-02-15`]]],[`KW`,[[`KWD`,`1961-04-01`,null]]],[`KY`,[[`KYD`,`1971-01-01`,null],[`JMD`,`1969-09-08`,`1971-01-01`]]],[`KZ`,[[`KZT`,`1993-11-05`,null]]],[`LA`,[[`LAK`,`1979-12-10`,null]]],[`LB`,[[`LBP`,`1948-02-02`,null]]],[`LC`,[[`XCD`,`1965-10-06`,null]]],[`LI`,[[`CHF`,`1921-02-01`,null]]],[`LK`,[[`LKR`,`1978-05-22`,null]]],[`LR`,[[`LRD`,`1944-01-01`,null]]],[`LS`,[[`ZAR`,`1961-02-14`,null],[`LSL`,`1980-01-22`,null]]],[`LT`,[[`EUR`,`2015-01-01`,null],[`LTL`,`1993-06-25`,`2014-12-31`],[`LTT`,`1992-10-01`,`1993-06-25`],[`SUR`,`1961-01-01`,`1992-10-01`]]],[`LU`,[[`EUR`,`1999-01-01`,null],[`LUF`,`1944-09-04`,`2002-02-28`]]],[`LV`,[[`EUR`,`2014-01-01`,null],[`LVL`,`1993-06-28`,`2013-12-31`],[`LVR`,`1992-05-07`,`1993-10-17`],[`SUR`,`1961-01-01`,`1992-07-20`]]],[`LY`,[[`LYD`,`1971-09-01`,null]]],[`MA`,[[`MAD`,`1959-10-17`,null],[`MAF`,`1881-01-01`,`1959-10-17`]]],[`MC`,[[`EUR`,`1999-01-01`,null],[`FRF`,`1960-01-01`,`2002-02-17`],[`MCF`,`1960-01-01`,`2002-02-17`]]],[`MD`,[[`MDL`,`1993-11-29`,null],[`MDC`,`1992-06-01`,`1993-11-29`]]],[`ME`,[[`EUR`,`2002-01-01`,null],[`DEM`,`1999-10-02`,`2002-05-15`],[`YUM`,`1994-01-24`,`2002-05-15`]]],[`MF`,[[`EUR`,`1999-01-01`,null],[`FRF`,`1960-01-01`,`2002-02-17`]]],[`MG`,[[`MGA`,`1983-11-01`,null],[`MGF`,`1963-07-01`,`2004-12-31`]]],[`MH`,[[`USD`,`1944-01-01`,null]]],[`MK`,[[`MKD`,`1993-05-20`,null],[`MKN`,`1992-04-26`,`1993-05-20`]]],[`ML`,[[`XOF`,`1984-06-01`,null],[`MLF`,`1962-07-02`,`1984-08-31`],[`XOF`,`1958-11-24`,`1962-07-02`]]],[`MM`,[[`MMK`,`1989-06-18`,null],[`BUK`,`1952-07-01`,`1989-06-18`]]],[`MN`,[[`MNT`,`1915-03-01`,null]]],[`MO`,[[`MOP`,`1901-01-01`,null]]],[`MP`,[[`USD`,`1944-01-01`,null]]],[`MQ`,[[`EUR`,`1999-01-01`,null],[`FRF`,`1960-01-01`,`2002-02-17`]]],[`MR`,[[`MRU`,`2018-01-01`,null],[`MRO`,`1973-06-29`,`2018-06-30`],[`XOF`,`1958-11-28`,`1973-06-29`]]],[`MS`,[[`XCD`,`1967-02-27`,null]]],[`MT`,[[`EUR`,`2008-01-01`,null],[`MTL`,`1968-06-07`,`2008-01-31`],[`MTP`,`1914-08-13`,`1968-06-07`]]],[`MU`,[[`MUR`,`1934-04-01`,null]]],[`MV`,[[`MVR`,`1981-07-01`,null],[`MVP`,`1947-01-01`,`1981-07-01`]]],[`MW`,[[`MWK`,`1971-02-15`,null]]],[`MX`,[[`MXN`,`1993-01-01`,null],[`MXP`,`1822-01-01`,`1992-12-31`]]],[`MY`,[[`MYR`,`1963-09-16`,null]]],[`MZ`,[[`MZN`,`2006-07-01`,null],[`MZM`,`1980-06-16`,`2006-12-31`],[`MZE`,`1975-06-25`,`1980-06-16`]]],[`NA`,[[`NAD`,`1993-01-01`,null],[`ZAR`,`1961-02-14`,null]]],[`NC`,[[`XPF`,`1985-01-01`,null]]],[`NE`,[[`XOF`,`1958-12-19`,null]]],[`NF`,[[`AUD`,`1966-02-14`,null]]],[`NG`,[[`NGN`,`1973-01-01`,null]]],[`NI`,[[`NIO`,`1991-04-30`,null],[`NIC`,`1988-02-15`,`1991-04-30`]]],[`NL`,[[`EUR`,`1999-01-01`,null],[`NLG`,`1813-01-01`,`2002-02-28`]]],[`NO`,[[`NOK`,`1905-06-07`,null],[`SEK`,`1873-05-27`,`1905-06-07`]]],[`NP`,[[`NPR`,`1933-01-01`,null],[`INR`,`1870-01-01`,`1966-10-17`]]],[`NR`,[[`AUD`,`1966-02-14`,null]]],[`NU`,[[`NZD`,`1967-07-10`,null]]],[`NZ`,[[`NZD`,`1967-07-10`,null]]],[`OM`,[[`OMR`,`1972-11-11`,null]]],[`PA`,[[`PAB`,`1903-11-04`,null],[`USD`,`1903-11-18`,null]]],[`PE`,[[`PEN`,`1991-07-01`,null],[`PEI`,`1985-02-01`,`1991-07-01`],[`PES`,`1863-02-14`,`1985-02-01`]]],[`PF`,[[`XPF`,`1945-12-26`,null]]],[`PG`,[[`PGK`,`1975-09-16`,null],[`AUD`,`1966-02-14`,`1975-09-16`]]],[`PH`,[[`PHP`,`1946-07-04`,null]]],[`PK`,[[`PKR`,`1948-04-01`,null],[`INR`,`1835-08-17`,`1947-08-15`]]],[`PL`,[[`PLN`,`1995-01-01`,null],[`PLZ`,`1950-10-28`,`1994-12-31`]]],[`PM`,[[`EUR`,`1999-01-01`,null],[`FRF`,`1972-12-21`,`2002-02-17`]]],[`PN`,[[`NZD`,`1969-01-13`,null]]],[`PR`,[[`USD`,`1898-12-10`,null],[`ESP`,`1800-01-01`,`1898-12-10`]]],[`PS`,[[`ILS`,`1985-09-04`,null],[`JOD`,`1996-02-12`,null],[`ILP`,`1967-06-01`,`1980-02-22`],[`JOD`,`1950-07-01`,`1967-06-01`]]],[`PT`,[[`EUR`,`1999-01-01`,null],[`PTE`,`1911-05-22`,`2002-02-28`]]],[`PW`,[[`USD`,`1944-01-01`,null]]],[`PY`,[[`PYG`,`1943-11-01`,null]]],[`QA`,[[`QAR`,`1973-05-19`,null]]],[`RE`,[[`EUR`,`1999-01-01`,null],[`FRF`,`1975-01-01`,`2002-02-17`]]],[`RO`,[[`RON`,`2005-07-01`,null],[`ROL`,`1952-01-28`,`2006-12-31`]]],[`RS`,[[`RSD`,`2006-10-25`,null],[`CSD`,`2002-05-15`,`2006-10-25`],[`YUM`,`1994-01-24`,`2002-05-15`]]],[`RU`,[[`RUB`,`1999-01-01`,null],[`RUR`,`1991-12-25`,`1998-12-31`]]],[`RW`,[[`RWF`,`1964-05-19`,null]]],[`SA`,[[`SAR`,`1952-10-22`,null]]],[`SB`,[[`SBD`,`1977-10-24`,null],[`AUD`,`1966-02-14`,`1978-06-30`]]],[`SC`,[[`SCR`,`1903-11-01`,null]]],[`SD`,[[`SDG`,`2007-01-10`,null],[`SDD`,`1992-06-08`,`2007-06-30`],[`SDP`,`1957-04-08`,`1998-06-01`],[`EGP`,`1889-01-19`,`1958-01-01`],[`GBP`,`1889-01-19`,`1958-01-01`]]],[`SE`,[[`SEK`,`1873-05-27`,null]]],[`SG`,[[`SGD`,`1967-06-12`,null],[`MYR`,`1963-09-16`,`1967-06-12`]]],[`SH`,[[`SHP`,`1917-02-15`,null]]],[`SI`,[[`EUR`,`2007-01-01`,null],[`SIT`,`1992-10-07`,`2007-01-14`]]],[`SJ`,[[`NOK`,`1905-06-07`,null]]],[`SK`,[[`EUR`,`2009-01-01`,null],[`SKK`,`1992-12-31`,`2009-01-01`],[`CSK`,`1953-06-01`,`1992-12-31`]]],[`SL`,[[`SLE`,`2022-07-01`,null],[`SLL`,`1964-08-04`,`2023-12-31`],[`GBP`,`1808-11-30`,`1966-02-04`]]],[`SM`,[[`EUR`,`1999-01-01`,null],[`ITL`,`1865-12-23`,`2001-02-28`]]],[`SN`,[[`XOF`,`1959-04-04`,null]]],[`SO`,[[`SOS`,`1960-07-01`,null]]],[`SR`,[[`SRD`,`2004-01-01`,null],[`SRG`,`1940-05-10`,`2003-12-31`],[`NLG`,`1815-11-20`,`1940-05-10`]]],[`SS`,[[`SSP`,`2011-07-18`,null],[`SDG`,`2007-01-10`,`2011-09-01`]]],[`ST`,[[`STN`,`2018-01-01`,null],[`STD`,`1977-09-08`,`2017-12-31`]]],[`SU`,[[`SUR`,`1961-01-01`,`1991-12-25`]]],[`SV`,[[`USD`,`2001-01-01`,null],[`SVC`,`1919-11-11`,`2001-01-01`]]],[`SX`,[[`XCG`,`2025-03-31`,null],[`ANG`,`2010-10-10`,`2025-06-30`]]],[`SY`,[[`SYP`,`1948-01-01`,null]]],[`SZ`,[[`SZL`,`1974-09-06`,null]]],[`TA`,[[`GBP`,`1938-01-12`,null]]],[`TC`,[[`USD`,`1969-09-08`,null]]],[`TD`,[[`XAF`,`1993-01-01`,null]]],[`TF`,[[`EUR`,`1999-01-01`,null],[`FRF`,`1959-01-01`,`2002-02-17`]]],[`TG`,[[`XOF`,`1958-11-28`,null]]],[`TH`,[[`THB`,`1928-04-15`,null]]],[`TJ`,[[`TJS`,`2000-10-26`,null],[`TJR`,`1995-05-10`,`2000-10-25`],[`RUR`,`1991-12-25`,`1995-05-10`]]],[`TK`,[[`NZD`,`1967-07-10`,null]]],[`TL`,[[`USD`,`1999-10-20`,null],[`TPE`,`1959-01-02`,`2002-05-20`],[`IDR`,`1975-12-07`,`2002-05-20`]]],[`TM`,[[`TMT`,`2009-01-01`,null],[`TMM`,`1993-11-01`,`2009-01-01`],[`RUR`,`1991-12-25`,`1993-11-01`],[`SUR`,`1961-01-01`,`1991-12-25`]]],[`TN`,[[`TND`,`1958-11-01`,null]]],[`TO`,[[`TOP`,`1966-02-14`,null]]],[`TP`,[[`TPE`,`1959-01-02`,`2002-05-20`],[`IDR`,`1975-12-07`,`2002-05-20`]]],[`TR`,[[`TRY`,`2005-01-01`,null],[`TRL`,`1922-11-01`,`2005-12-31`]]],[`TT`,[[`TTD`,`1964-01-01`,null]]],[`TV`,[[`AUD`,`1966-02-14`,null]]],[`TW`,[[`TWD`,`1949-06-15`,null]]],[`TZ`,[[`TZS`,`1966-06-14`,null]]],[`UA`,[[`UAH`,`1996-09-02`,null],[`UAK`,`1992-11-13`,`1993-10-17`],[`RUR`,`1991-12-25`,`1992-11-13`],[`SUR`,`1961-01-01`,`1991-12-25`]]],[`UG`,[[`UGX`,`1987-05-15`,null],[`UGS`,`1966-08-15`,`1987-05-15`]]],[`UM`,[[`USD`,`1944-01-01`,null]]],[`US`,[[`USD`,`1792-01-01`,null]]],[`UY`,[[`UYU`,`1993-03-01`,null],[`UYP`,`1975-07-01`,`1993-03-01`]]],[`UZ`,[[`UZS`,`1994-07-01`,null]]],[`VA`,[[`EUR`,`1999-01-01`,null],[`ITL`,`1870-10-19`,`2002-02-28`]]],[`VC`,[[`XCD`,`1965-10-06`,null]]],[`VE`,[[`VES`,`2018-08-20`,null],[`VEF`,`2008-01-01`,`2018-08-20`],[`VEB`,`1871-05-11`,`2008-06-30`]]],[`VG`,[[`USD`,`1833-01-01`,null],[`GBP`,`1833-01-01`,`1959-01-01`]]],[`VI`,[[`USD`,`1837-01-01`,null]]],[`VN`,[[`VND`,`1985-09-14`,null],[`VNN`,`1978-05-03`,`1985-09-14`]]],[`VU`,[[`VUV`,`1981-01-01`,null]]],[`WF`,[[`XPF`,`1961-07-30`,null]]],[`WS`,[[`WST`,`1967-07-10`,null]]],[`XK`,[[`EUR`,`2002-01-01`,null],[`DEM`,`1999-09-01`,`2002-03-09`],[`YUM`,`1994-01-24`,`1999-09-30`]]],[`YD`,[[`YDD`,`1965-04-01`,`1996-01-01`]]],[`YE`,[[`YER`,`1990-05-22`,null]]],[`YT`,[[`EUR`,`1999-01-01`,null],[`FRF`,`1976-02-23`,`2002-02-17`],[`KMF`,`1975-01-01`,`1976-02-23`]]],[`YU`,[[`YUM`,`1994-01-24`,`2002-05-15`],[`YUN`,`1990-01-01`,`1992-07-24`],[`YUD`,`1966-01-01`,`1990-01-01`]]],[`ZA`,[[`ZAR`,`1961-02-14`,null]]],[`ZM`,[[`ZMW`,`2013-01-01`,null],[`ZMK`,`1968-01-16`,`2013-01-01`]]],[`ZR`,[[`ZRN`,`1993-11-01`,`1998-07-31`],[`ZRZ`,`1971-10-27`,`1993-11-01`]]],[`ZW`,[[`ZWG`,`2024-06-25`,null],[`USD`,`2009-04-12`,null],[`ZWL`,`2009-02-02`,`2024-08-31`],[`ZWR`,`2008-08-01`,`2009-02-02`],[`ZWD`,`1980-04-18`,`2008-08-01`],[`RHD`,`1970-02-17`,`1980-04-18`]]],[`ZZ`,[]]]),r=`49.0.0`,i=/^[A-Z]{3}$/;function a(t,r=/* @__PURE__ */ new Date){e(t);let i=t.toUpperCase(),a=r.toISOString().slice(0,10);return(n.get(i)??[]).filter(([,e,t])=>(e===null||e<=a)&&(t===null||a<=t)).map(([e])=>e)}function o(e,t){return a(e,t)[0]}function s(n){e(n);let r=n.toUpperCase();if(!i.test(r))throw RangeError(`Invalid currency: ${n}`);let[a,o,s,c]=t.get(r)??t.get(`DEFAULT`);return{fractionDigits:a,roundingIncrement:o,cashFractionDigits:s,cashRoundingIncrement:c}}var c={getCurrency:o,getCurrencies:a,getCurrencyRounding:s,VERSION:r};export{r as VERSION,c as default,a as getCurrencies,o as getCurrency,s as getCurrencyRounding};
package/package.json CHANGED
@@ -1 +1,39 @@
1
- {"name":"cldr-region-currency","version":"0.0.0"}
1
+ {
2
+ "name": "cldr-region-currency",
3
+ "version": "1.0.0",
4
+ "description": "Find the currency used in a country or region, now or on a given date, based on the Unicode CLDR",
5
+ "keywords": [
6
+ "unicode",
7
+ "cldr",
8
+ "currency",
9
+ "iso-4217",
10
+ "country",
11
+ "region",
12
+ "i18n"
13
+ ],
14
+ "license": "MIT",
15
+ "author": "Aviv Keller <me@aviv.sh>",
16
+ "type": "module",
17
+ "main": "./index.mjs",
18
+ "types": "./index.d.mts",
19
+ "exports": {
20
+ ".": {
21
+ "types": "./index.d.mts",
22
+ "default": "./index.mjs"
23
+ }
24
+ },
25
+ "files": [
26
+ "index.mjs",
27
+ "index.d.mts"
28
+ ],
29
+ "sideEffects": false,
30
+ "repository": {
31
+ "type": "git",
32
+ "url": "git+https://github.com/avivkeller/unicode-packages.git",
33
+ "directory": "packages/cldr/region-currency"
34
+ },
35
+ "bugs": {
36
+ "url": "https://github.com/avivkeller/unicode-packages/issues"
37
+ },
38
+ "homepage": "https://github.com/avivkeller/unicode-packages/tree/main/packages/cldr/region-currency#readme"
39
+ }