@formatjs/utils 1.9.4 → 2.0.1
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/index.d.ts +5 -5
- package/index.js +5 -14
- package/package.json +7 -4
- package/src/countryCodes.js +2 -6
- package/src/defaultCurrency.js +5 -10
- package/src/defaultLocale.js +4 -8
- package/src/defaultTimezone.js +7 -10
- package/src/iso4217.js +2 -6
- package/lib/index.d.ts +0 -5
- package/lib/index.js +0 -5
- package/lib/src/countryCodes.d.ts +0 -6
- package/lib/src/countryCodes.js +0 -18
- package/lib/src/currencyMinorUnits.d.ts +0 -8
- package/lib/src/currencyMinorUnits.generated.json +0 -1
- package/lib/src/currencyMinorUnits.js +0 -15
- package/lib/src/defaultCurrency.d.ts +0 -12
- package/lib/src/defaultCurrency.js +0 -27
- package/lib/src/defaultCurrencyData.generated.json +0 -1
- package/lib/src/defaultLocale.d.ts +0 -6
- package/lib/src/defaultLocale.js +0 -11
- package/lib/src/defaultLocaleData.generated.json +0 -1
- package/lib/src/defaultTimezone.d.ts +0 -8
- package/lib/src/defaultTimezone.js +0 -53
- package/lib/src/iso3166Alpha3CountryCodes.json +0 -241
- package/lib/src/iso4217.d.ts +0 -10
- package/lib/src/iso4217.js +0 -27
- package/src/currencyMinorUnits.d.ts +0 -8
- package/src/currencyMinorUnits.js +0 -19
package/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { canonicalizeCountryCode } from './src/countryCodes';
|
|
2
|
-
export { countriesUsingDefaultCurrency, defaultCurrency, } from './src/defaultCurrency';
|
|
3
|
-
export { defaultLocale } from './src/defaultLocale';
|
|
4
|
-
export { defaultTimezone } from './src/defaultTimezone';
|
|
5
|
-
export { currencyMinorScale } from './src/iso4217';
|
|
1
|
+
export { canonicalizeCountryCode } from './src/countryCodes.js';
|
|
2
|
+
export { countriesUsingDefaultCurrency, defaultCurrency, } from './src/defaultCurrency.js';
|
|
3
|
+
export { defaultLocale } from './src/defaultLocale.js';
|
|
4
|
+
export { defaultTimezone } from './src/defaultTimezone.js';
|
|
5
|
+
export { currencyMinorScale } from './src/iso4217.js';
|
package/index.js
CHANGED
|
@@ -1,14 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
var defaultCurrency_1 = require("./src/defaultCurrency");
|
|
7
|
-
Object.defineProperty(exports, "countriesUsingDefaultCurrency", { enumerable: true, get: function () { return defaultCurrency_1.countriesUsingDefaultCurrency; } });
|
|
8
|
-
Object.defineProperty(exports, "defaultCurrency", { enumerable: true, get: function () { return defaultCurrency_1.defaultCurrency; } });
|
|
9
|
-
var defaultLocale_1 = require("./src/defaultLocale");
|
|
10
|
-
Object.defineProperty(exports, "defaultLocale", { enumerable: true, get: function () { return defaultLocale_1.defaultLocale; } });
|
|
11
|
-
var defaultTimezone_1 = require("./src/defaultTimezone");
|
|
12
|
-
Object.defineProperty(exports, "defaultTimezone", { enumerable: true, get: function () { return defaultTimezone_1.defaultTimezone; } });
|
|
13
|
-
var iso4217_1 = require("./src/iso4217");
|
|
14
|
-
Object.defineProperty(exports, "currencyMinorScale", { enumerable: true, get: function () { return iso4217_1.currencyMinorScale; } });
|
|
1
|
+
export { canonicalizeCountryCode } from './src/countryCodes.js';
|
|
2
|
+
export { countriesUsingDefaultCurrency, defaultCurrency, } from './src/defaultCurrency.js';
|
|
3
|
+
export { defaultLocale } from './src/defaultLocale.js';
|
|
4
|
+
export { defaultTimezone } from './src/defaultTimezone.js';
|
|
5
|
+
export { currencyMinorScale } from './src/iso4217.js';
|
package/package.json
CHANGED
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@formatjs/utils",
|
|
3
3
|
"description": "Collection of useful intl utilities",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "2.0.1",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Long Ho <holevietlong@gmail.com>",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"types": "index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": "./index.js"
|
|
11
|
+
},
|
|
7
12
|
"dependencies": {
|
|
8
13
|
"tslib": "^2.8.0",
|
|
9
|
-
"@formatjs/fast-memoize": "
|
|
14
|
+
"@formatjs/fast-memoize": "3.0.1"
|
|
10
15
|
},
|
|
11
16
|
"devDependencies": {
|
|
12
17
|
"fast-xml-parser": "^5.0.9"
|
|
@@ -19,7 +24,5 @@
|
|
|
19
24
|
"memoize",
|
|
20
25
|
"utils"
|
|
21
26
|
],
|
|
22
|
-
"main": "index.js",
|
|
23
|
-
"module": "lib/index.js",
|
|
24
27
|
"repository": "formatjs/formatjs.git"
|
|
25
28
|
}
|
package/src/countryCodes.js
CHANGED
|
@@ -1,15 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.canonicalizeCountryCode = canonicalizeCountryCode;
|
|
4
|
-
var tslib_1 = require("tslib");
|
|
5
|
-
var alpha3CountryCodes = tslib_1.__importStar(require("./iso3166Alpha3CountryCodes.json"));
|
|
1
|
+
import * as alpha3CountryCodes from './iso3166Alpha3CountryCodes.json';
|
|
6
2
|
var COUNTRY_CODE_ALPHA2 = new Set(Object.keys(alpha3CountryCodes).map(function (key) { return alpha3CountryCodes[key]; }));
|
|
7
3
|
/**
|
|
8
4
|
* Canonicalize a country code to a alpha2 country code (uppercase).
|
|
9
5
|
* @param alpha3OrAlpha2 - 2 or 3 letter country code (case-insensitive)
|
|
10
6
|
* @returns canonicalized 2 letter country code (uppercase) or undefined if not found
|
|
11
7
|
*/
|
|
12
|
-
function canonicalizeCountryCode(alpha3OrAlpha2) {
|
|
8
|
+
export function canonicalizeCountryCode(alpha3OrAlpha2) {
|
|
13
9
|
if (!alpha3OrAlpha2) {
|
|
14
10
|
return;
|
|
15
11
|
}
|
package/src/defaultCurrency.js
CHANGED
|
@@ -1,10 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.defaultCurrency = defaultCurrency;
|
|
4
|
-
exports.countriesUsingDefaultCurrency = countriesUsingDefaultCurrency;
|
|
5
|
-
var tslib_1 = require("tslib");
|
|
6
|
-
var countryCodes_1 = require("./countryCodes");
|
|
7
|
-
var data = tslib_1.__importStar(require("./defaultCurrencyData.generated.json"));
|
|
1
|
+
import { canonicalizeCountryCode } from './countryCodes.js';
|
|
2
|
+
import * as data from './defaultCurrencyData.generated.json';
|
|
8
3
|
var COUNTRIES_BY_DEFAULT_CURRENCY = Object.keys(data).reduce(function (acc, countryCode) {
|
|
9
4
|
var currencyCode = data[countryCode];
|
|
10
5
|
if (!acc[currencyCode]) {
|
|
@@ -18,8 +13,8 @@ var COUNTRIES_BY_DEFAULT_CURRENCY = Object.keys(data).reduce(function (acc, coun
|
|
|
18
13
|
* @param countryCode country code (alpha-2)
|
|
19
14
|
* @returns default currency code, or USD if not found
|
|
20
15
|
*/
|
|
21
|
-
function defaultCurrency(countryCode) {
|
|
22
|
-
countryCode =
|
|
16
|
+
export function defaultCurrency(countryCode) {
|
|
17
|
+
countryCode = canonicalizeCountryCode(countryCode);
|
|
23
18
|
return ((countryCode && countryCode in data && data[countryCode]) || 'USD');
|
|
24
19
|
}
|
|
25
20
|
/**
|
|
@@ -27,6 +22,6 @@ function defaultCurrency(countryCode) {
|
|
|
27
22
|
* @param currencyCode currency code (ISO 4217)
|
|
28
23
|
* @returns list of country codes (alpha-2)
|
|
29
24
|
*/
|
|
30
|
-
function countriesUsingDefaultCurrency(currencyCode) {
|
|
25
|
+
export function countriesUsingDefaultCurrency(currencyCode) {
|
|
31
26
|
return COUNTRIES_BY_DEFAULT_CURRENCY[currencyCode || 'USD'] || [];
|
|
32
27
|
}
|
package/src/defaultLocale.js
CHANGED
|
@@ -1,15 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.defaultLocale = defaultLocale;
|
|
4
|
-
var tslib_1 = require("tslib");
|
|
5
|
-
var countryCodes_1 = require("./countryCodes");
|
|
6
|
-
var data = tslib_1.__importStar(require("./defaultLocaleData.generated.json"));
|
|
1
|
+
import { canonicalizeCountryCode } from './countryCodes.js';
|
|
2
|
+
import * as data from './defaultLocaleData.generated.json';
|
|
7
3
|
/**
|
|
8
4
|
* Look up default locale for a country code.
|
|
9
5
|
* @param countryCode country code (alpha-2)
|
|
10
6
|
* @returns default locale, or en if not found
|
|
11
7
|
*/
|
|
12
|
-
function defaultLocale(countryCode) {
|
|
13
|
-
countryCode =
|
|
8
|
+
export function defaultLocale(countryCode) {
|
|
9
|
+
countryCode = canonicalizeCountryCode(countryCode);
|
|
14
10
|
return ((countryCode && countryCode in data && data[countryCode]) || 'en');
|
|
15
11
|
}
|
package/src/defaultTimezone.js
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.defaultTimezone = defaultTimezone;
|
|
4
|
-
var tslib_1 = require("tslib");
|
|
5
|
-
var fast_memoize_1 = require("@formatjs/fast-memoize");
|
|
1
|
+
import { __spreadArray } from "tslib";
|
|
2
|
+
import { memoize, strategies } from '@formatjs/fast-memoize';
|
|
6
3
|
var cache = {};
|
|
7
4
|
function createFastMemoizeCache(store) {
|
|
8
5
|
return {
|
|
@@ -18,16 +15,16 @@ function createFastMemoizeCache(store) {
|
|
|
18
15
|
},
|
|
19
16
|
};
|
|
20
17
|
}
|
|
21
|
-
var getDateTimeFormat =
|
|
18
|
+
var getDateTimeFormat = memoize(function () {
|
|
22
19
|
var _a;
|
|
23
20
|
var args = [];
|
|
24
21
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
25
22
|
args[_i] = arguments[_i];
|
|
26
23
|
}
|
|
27
|
-
return new ((_a = Intl.DateTimeFormat).bind.apply(_a,
|
|
24
|
+
return new ((_a = Intl.DateTimeFormat).bind.apply(_a, __spreadArray([void 0], args, false)))();
|
|
28
25
|
}, {
|
|
29
26
|
cache: createFastMemoizeCache(cache),
|
|
30
|
-
strategy:
|
|
27
|
+
strategy: strategies.variadic,
|
|
31
28
|
});
|
|
32
29
|
var now = Date.now();
|
|
33
30
|
/**
|
|
@@ -35,7 +32,7 @@ var now = Date.now();
|
|
|
35
32
|
* @param dateDateTimeFormatCreator creator fn for Intl.DateTimeFormat
|
|
36
33
|
* @returns default timezone for the system
|
|
37
34
|
*/
|
|
38
|
-
function defaultTimezone(locales, options) {
|
|
35
|
+
export function defaultTimezone(locales, options) {
|
|
39
36
|
var _a;
|
|
40
37
|
var timeZoneName = options === null || options === void 0 ? void 0 : options.timeZoneName;
|
|
41
38
|
try {
|
|
@@ -50,7 +47,7 @@ function defaultTimezone(locales, options) {
|
|
|
50
47
|
return (((_a = dtf.formatToParts(now).find(function (p) { return p.type === 'timeZoneName'; })) === null || _a === void 0 ? void 0 : _a.value) ||
|
|
51
48
|
'UTC');
|
|
52
49
|
}
|
|
53
|
-
catch (
|
|
50
|
+
catch (_b) {
|
|
54
51
|
return 'UTC';
|
|
55
52
|
}
|
|
56
53
|
}
|
package/src/iso4217.js
CHANGED
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.currencyMinorScale = currencyMinorScale;
|
|
4
|
-
var tslib_1 = require("tslib");
|
|
5
|
-
var iso4217 = tslib_1.__importStar(require("./currencyMinorUnits.generated.json"));
|
|
1
|
+
import * as iso4217 from './currencyMinorUnits.generated.json';
|
|
6
2
|
/**
|
|
7
3
|
* Returns the number of minor units (decimal places) for a given currency code.
|
|
8
4
|
*
|
|
@@ -26,6 +22,6 @@ function currencyMinorUnits(currencyCode) {
|
|
|
26
22
|
* @param currencyCode - The ISO 4217 currency code (e.g., 'USD', 'EUR').
|
|
27
23
|
* @returns The minor unit scale as a power of 10.
|
|
28
24
|
*/
|
|
29
|
-
function currencyMinorScale(currencyCode) {
|
|
25
|
+
export function currencyMinorScale(currencyCode) {
|
|
30
26
|
return Math.pow(10, currencyMinorUnits(currencyCode));
|
|
31
27
|
}
|
package/lib/index.d.ts
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
export { canonicalizeCountryCode } from './src/countryCodes';
|
|
2
|
-
export { countriesUsingDefaultCurrency, defaultCurrency, } from './src/defaultCurrency';
|
|
3
|
-
export { defaultLocale } from './src/defaultLocale';
|
|
4
|
-
export { defaultTimezone } from './src/defaultTimezone';
|
|
5
|
-
export { currencyMinorScale } from './src/iso4217';
|
package/lib/index.js
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
export { canonicalizeCountryCode } from './src/countryCodes';
|
|
2
|
-
export { countriesUsingDefaultCurrency, defaultCurrency, } from './src/defaultCurrency';
|
|
3
|
-
export { defaultLocale } from './src/defaultLocale';
|
|
4
|
-
export { defaultTimezone } from './src/defaultTimezone';
|
|
5
|
-
export { currencyMinorScale } from './src/iso4217';
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Canonicalize a country code to a alpha2 country code (uppercase).
|
|
3
|
-
* @param alpha3OrAlpha2 - 2 or 3 letter country code (case-insensitive)
|
|
4
|
-
* @returns canonicalized 2 letter country code (uppercase) or undefined if not found
|
|
5
|
-
*/
|
|
6
|
-
export declare function canonicalizeCountryCode(alpha3OrAlpha2?: string): string | undefined;
|
package/lib/src/countryCodes.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import * as alpha3CountryCodes from './iso3166Alpha3CountryCodes.json';
|
|
2
|
-
var COUNTRY_CODE_ALPHA2 = new Set(Object.keys(alpha3CountryCodes).map(function (key) { return alpha3CountryCodes[key]; }));
|
|
3
|
-
/**
|
|
4
|
-
* Canonicalize a country code to a alpha2 country code (uppercase).
|
|
5
|
-
* @param alpha3OrAlpha2 - 2 or 3 letter country code (case-insensitive)
|
|
6
|
-
* @returns canonicalized 2 letter country code (uppercase) or undefined if not found
|
|
7
|
-
*/
|
|
8
|
-
export function canonicalizeCountryCode(alpha3OrAlpha2) {
|
|
9
|
-
if (!alpha3OrAlpha2) {
|
|
10
|
-
return;
|
|
11
|
-
}
|
|
12
|
-
var upper = alpha3OrAlpha2.toUpperCase();
|
|
13
|
-
// Lenient here, if it's already a 2 letter code, just return it
|
|
14
|
-
if (upper.length === 2) {
|
|
15
|
-
return COUNTRY_CODE_ALPHA2.has(upper) ? upper : undefined;
|
|
16
|
-
}
|
|
17
|
-
return alpha3CountryCodes[upper];
|
|
18
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Returns the number of minor units (decimal places) for a given currency code.
|
|
3
|
-
*
|
|
4
|
-
* @param currencyCode - The ISO 4217 currency code (e.g., 'USD', 'EUR').
|
|
5
|
-
* @returns The number of minor units for the specified currency.
|
|
6
|
-
* @throws Will throw an error if the currency code is unknown.
|
|
7
|
-
*/
|
|
8
|
-
export declare function currencyMinorUnits(currencyCode: string): number;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{ "AFN": 2, "EUR": 2, "ALL": 2, "DZD": 2, "USD": 2, "AOA": 2, "XCD": 2, "XAD": 2, "ARS": 2, "AMD": 2, "AWG": 2, "AUD": 2, "AZN": 2, "BSD": 2, "BHD": 3, "BDT": 2, "BBD": 2, "BYN": 2, "BZD": 2, "XOF": 0, "BMD": 2, "INR": 2, "BTN": 2, "BOB": 2, "BOV": 2, "BAM": 2, "BWP": 2, "NOK": 2, "BRL": 2, "BND": 2, "BGN": 2, "BIF": 0, "CVE": 2, "KHR": 2, "XAF": 0, "CAD": 2, "KYD": 2, "CLP": 0, "CLF": 4, "CNY": 2, "COP": 2, "COU": 2, "KMF": 0, "CDF": 2, "NZD": 2, "CRC": 2, "CUP": 2, "XCG": 2, "CZK": 2, "DKK": 2, "DJF": 0, "DOP": 2, "EGP": 2, "SVC": 2, "ERN": 2, "SZL": 2, "ETB": 2, "FKP": 2, "FJD": 2, "XPF": 0, "GMD": 2, "GEL": 2, "GHS": 2, "GIP": 2, "GTQ": 2, "GBP": 2, "GNF": 0, "GYD": 2, "HTG": 2, "HNL": 2, "HKD": 2, "HUF": 2, "ISK": 0, "IDR": 2, "IRR": 2, "IQD": 3, "ILS": 2, "JMD": 2, "JPY": 0, "JOD": 3, "KZT": 2, "KES": 2, "KPW": 2, "KRW": 0, "KWD": 3, "KGS": 2, "LAK": 2, "LBP": 2, "LSL": 2, "ZAR": 2, "LRD": 2, "LYD": 3, "CHF": 2, "MOP": 2, "MKD": 2, "MGA": 2, "MWK": 2, "MYR": 2, "MVR": 2, "MRU": 2, "MUR": 2, "MXN": 2, "MXV": 2, "MDL": 2, "MNT": 2, "MAD": 2, "MZN": 2, "MMK": 2, "NAD": 2, "NPR": 2, "NIO": 2, "NGN": 2, "OMR": 3, "PKR": 2, "PAB": 2, "PGK": 2, "PYG": 0, "PEN": 2, "PHP": 2, "PLN": 2, "QAR": 2, "RON": 2, "RUB": 2, "RWF": 0, "SHP": 2, "WST": 2, "STN": 2, "SAR": 2, "RSD": 2, "SCR": 2, "SLE": 2, "SGD": 2, "SBD": 2, "SOS": 2, "SSP": 2, "LKR": 2, "SDG": 2, "SRD": 2, "SEK": 2, "CHE": 2, "CHW": 2, "SYP": 2, "TWD": 2, "TJS": 2, "TZS": 2, "THB": 2, "TOP": 2, "TTD": 2, "TND": 3, "TRY": 2, "TMT": 2, "UGX": 0, "UAH": 2, "AED": 2, "USN": 2, "UYU": 2, "UYI": 0, "UYW": 4, "UZS": 2, "VUV": 0, "VES": 2, "VED": 2, "VND": 0, "YER": 2, "ZMW": 2, "ZWG": 2 }
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import * as iso4217 from './currencyMinorUnits.generated.json';
|
|
2
|
-
/**
|
|
3
|
-
* Returns the number of minor units (decimal places) for a given currency code.
|
|
4
|
-
*
|
|
5
|
-
* @param currencyCode - The ISO 4217 currency code (e.g., 'USD', 'EUR').
|
|
6
|
-
* @returns The number of minor units for the specified currency.
|
|
7
|
-
* @throws Will throw an error if the currency code is unknown.
|
|
8
|
-
*/
|
|
9
|
-
export function currencyMinorUnits(currencyCode) {
|
|
10
|
-
var minorUnits = iso4217[currencyCode.toUpperCase()];
|
|
11
|
-
if (minorUnits == null) {
|
|
12
|
-
throw new Error("Unknown currency code: ".concat(currencyCode));
|
|
13
|
-
}
|
|
14
|
-
return minorUnits;
|
|
15
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Look up default currency for a country code.
|
|
3
|
-
* @param countryCode country code (alpha-2)
|
|
4
|
-
* @returns default currency code, or USD if not found
|
|
5
|
-
*/
|
|
6
|
-
export declare function defaultCurrency(countryCode?: string): string;
|
|
7
|
-
/**
|
|
8
|
-
* Look up countries using a default currency.
|
|
9
|
-
* @param currencyCode currency code (ISO 4217)
|
|
10
|
-
* @returns list of country codes (alpha-2)
|
|
11
|
-
*/
|
|
12
|
-
export declare function countriesUsingDefaultCurrency(currencyCode?: string): string[];
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { canonicalizeCountryCode } from './countryCodes';
|
|
2
|
-
import * as data from './defaultCurrencyData.generated.json';
|
|
3
|
-
var COUNTRIES_BY_DEFAULT_CURRENCY = Object.keys(data).reduce(function (acc, countryCode) {
|
|
4
|
-
var currencyCode = data[countryCode];
|
|
5
|
-
if (!acc[currencyCode]) {
|
|
6
|
-
acc[currencyCode] = [];
|
|
7
|
-
}
|
|
8
|
-
acc[currencyCode].push(countryCode);
|
|
9
|
-
return acc;
|
|
10
|
-
}, {});
|
|
11
|
-
/**
|
|
12
|
-
* Look up default currency for a country code.
|
|
13
|
-
* @param countryCode country code (alpha-2)
|
|
14
|
-
* @returns default currency code, or USD if not found
|
|
15
|
-
*/
|
|
16
|
-
export function defaultCurrency(countryCode) {
|
|
17
|
-
countryCode = canonicalizeCountryCode(countryCode);
|
|
18
|
-
return ((countryCode && countryCode in data && data[countryCode]) || 'USD');
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Look up countries using a default currency.
|
|
22
|
-
* @param currencyCode currency code (ISO 4217)
|
|
23
|
-
* @returns list of country codes (alpha-2)
|
|
24
|
-
*/
|
|
25
|
-
export function countriesUsingDefaultCurrency(currencyCode) {
|
|
26
|
-
return COUNTRIES_BY_DEFAULT_CURRENCY[currencyCode || 'USD'] || [];
|
|
27
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{ "AC": "SHP", "AD": "EUR", "AE": "AED", "AF": "AFN", "AG": "XCD", "AI": "XCD", "AL": "ALL", "AM": "AMD", "AO": "AOA", "AR": "ARS", "AS": "USD", "AT": "EUR", "AU": "AUD", "AW": "AWG", "AX": "EUR", "AZ": "AZN", "BA": "BAM", "BB": "BBD", "BD": "BDT", "BE": "EUR", "BF": "XOF", "BG": "BGN", "BH": "BHD", "BI": "BIF", "BJ": "XOF", "BL": "EUR", "BM": "BMD", "BN": "BND", "BO": "BOB", "BQ": "USD", "BR": "BRL", "BS": "BSD", "BT": "INR", "BV": "NOK", "BW": "BWP", "BY": "BYN", "BZ": "BZD", "CA": "CAD", "CC": "AUD", "CD": "CDF", "CF": "XAF", "CG": "XAF", "CH": "CHF", "CI": "XOF", "CK": "NZD", "CL": "CLP", "CM": "XAF", "CN": "CNY", "CO": "COP", "CR": "CRC", "CU": "CUP", "CV": "CVE", "CW": "XCG", "CX": "AUD", "CY": "EUR", "CZ": "CZK", "DE": "EUR", "DG": "USD", "DJ": "DJF", "DK": "DKK", "DM": "XCD", "DO": "DOP", "DZ": "DZD", "EA": "EUR", "EC": "USD", "EE": "EUR", "EG": "EGP", "EH": "MAD", "ER": "ERN", "ES": "EUR", "ET": "ETB", "EU": "EUR", "FI": "EUR", "FJ": "FJD", "FK": "FKP", "FM": "USD", "FO": "DKK", "FR": "EUR", "GA": "XAF", "GB": "GBP", "GD": "XCD", "GE": "GEL", "GF": "EUR", "GG": "GBP", "GH": "GHS", "GI": "GIP", "GL": "DKK", "GM": "GMD", "GN": "GNF", "GP": "EUR", "GQ": "XAF", "GR": "EUR", "GS": "GBP", "GT": "GTQ", "GU": "USD", "GW": "XOF", "GY": "GYD", "HK": "HKD", "HM": "AUD", "HN": "HNL", "HR": "EUR", "HT": "USD", "HU": "HUF", "IC": "EUR", "ID": "IDR", "IE": "EUR", "IL": "ILS", "IM": "GBP", "IN": "INR", "IO": "USD", "IQ": "IQD", "IR": "IRR", "IS": "ISK", "IT": "EUR", "JE": "GBP", "JM": "JMD", "JO": "JOD", "JP": "JPY", "KE": "KES", "KG": "KGS", "KH": "KHR", "KI": "AUD", "KM": "KMF", "KN": "XCD", "KP": "KPW", "KR": "KRW", "KW": "KWD", "KY": "KYD", "KZ": "KZT", "LA": "LAK", "LB": "LBP", "LC": "XCD", "LI": "CHF", "LK": "LKR", "LR": "LRD", "LS": "ZAR", "LT": "EUR", "LU": "EUR", "LV": "EUR", "LY": "LYD", "MA": "MAD", "MC": "EUR", "MD": "MDL", "ME": "EUR", "MF": "EUR", "MG": "MGA", "MH": "USD", "MK": "MKD", "ML": "XOF", "MM": "MMK", "MN": "MNT", "MO": "MOP", "MP": "USD", "MQ": "EUR", "MR": "MRU", "MS": "XCD", "MT": "EUR", "MU": "MUR", "MV": "MVR", "MW": "MWK", "MX": "MXN", "MY": "MYR", "MZ": "MZN", "NA": "ZAR", "NC": "XPF", "NE": "XOF", "NF": "AUD", "NG": "NGN", "NI": "NIO", "NL": "EUR", "NO": "NOK", "NP": "NPR", "NR": "AUD", "NU": "NZD", "NZ": "NZD", "OM": "OMR", "PA": "USD", "PE": "PEN", "PF": "XPF", "PG": "PGK", "PH": "PHP", "PK": "PKR", "PL": "PLN", "PM": "EUR", "PN": "NZD", "PR": "USD", "PS": "JOD", "PT": "EUR", "PW": "USD", "PY": "PYG", "QA": "QAR", "RE": "EUR", "RO": "RON", "RS": "RSD", "RU": "RUB", "RW": "RWF", "SA": "SAR", "SB": "SBD", "SC": "SCR", "SD": "SDG", "SE": "SEK", "SG": "SGD", "SH": "SHP", "SI": "EUR", "SJ": "NOK", "SK": "EUR", "SL": "SLE", "SM": "EUR", "SN": "XOF", "SO": "SOS", "SR": "SRD", "SS": "SSP", "ST": "STN", "SV": "USD", "SX": "XCG", "SY": "SYP", "SZ": "SZL", "TA": "GBP", "TC": "USD", "TD": "XAF", "TF": "EUR", "TG": "XOF", "TH": "THB", "TJ": "TJS", "TK": "NZD", "TL": "USD", "TM": "TMT", "TN": "TND", "TO": "TOP", "TR": "TRY", "TT": "TTD", "TV": "AUD", "TW": "TWD", "TZ": "TZS", "UA": "UAH", "UG": "UGX", "UM": "USD", "US": "USD", "UY": "UYU", "UZ": "UZS", "VA": "EUR", "VC": "XCD", "VE": "VES", "VG": "USD", "VI": "USD", "VN": "VND", "VU": "VUV", "WF": "XPF", "WS": "WST", "XK": "EUR", "YE": "YER", "YT": "EUR", "ZA": "ZAR", "ZM": "ZMW", "ZW": "ZWG" }
|
package/lib/src/defaultLocale.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { canonicalizeCountryCode } from './countryCodes';
|
|
2
|
-
import * as data from './defaultLocaleData.generated.json';
|
|
3
|
-
/**
|
|
4
|
-
* Look up default locale for a country code.
|
|
5
|
-
* @param countryCode country code (alpha-2)
|
|
6
|
-
* @returns default locale, or en if not found
|
|
7
|
-
*/
|
|
8
|
-
export function defaultLocale(countryCode) {
|
|
9
|
-
countryCode = canonicalizeCountryCode(countryCode);
|
|
10
|
-
return ((countryCode && countryCode in data && data[countryCode]) || 'en');
|
|
11
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{ "AD": "ca-Latn-AD", "AE": "ar-Arab-AE", "AF": "fa-Arab-AF", "AL": "sq-Latn-AL", "AM": "hy-Armn-AM", "AO": "pt-Latn-AO", "AR": "es-Latn-AR", "AS": "sm-Latn-AS", "AT": "de-Latn-AT", "AW": "nl-Latn-AW", "AX": "sv-Latn-AX", "AZ": "az-Latn-AZ", "BA": "bs-Latn-BA", "BD": "bn-Beng-BD", "BE": "nl-Latn-BE", "BF": "fr-Latn-BF", "BG": "bg-Cyrl-BG", "BH": "ar-Arab-BH", "BI": "rn-Latn-BI", "BJ": "fr-Latn-BJ", "BL": "fr-Latn-BL", "BN": "ms-Latn-BN", "BO": "es-Latn-BO", "BQ": "pap-Latn-BQ", "BR": "pt-Latn-BR", "BT": "dz-Tibt-BT", "BY": "be-Cyrl-BY", "CC": "ms-Arab-CC", "CD": "sw-Latn-CD", "CF": "fr-Latn-CF", "CG": "fr-Latn-CG", "CH": "de-Latn-CH", "CI": "fr-Latn-CI", "CL": "es-Latn-CL", "CM": "fr-Latn-CM", "CN": "zh-Hans-CN", "CO": "es-Latn-CO", "CR": "es-Latn-CR", "CU": "es-Latn-CU", "CV": "pt-Latn-CV", "CW": "pap-Latn-CW", "CY": "el-Grek-CY", "CZ": "cs-Latn-CZ", "DE": "de-Latn-DE", "DJ": "aa-Latn-DJ", "DK": "da-Latn-DK", "DO": "es-Latn-DO", "DZ": "ar-Arab-DZ", "EA": "es-Latn-EA", "EC": "es-Latn-EC", "EE": "et-Latn-EE", "EG": "ar-Arab-EG", "EH": "ar-Arab-EH", "ER": "ti-Ethi-ER", "ES": "es-Latn-ES", "ET": "am-Ethi-ET", "FI": "fi-Latn-FI", "FO": "fo-Latn-FO", "FR": "fr-Latn-FR", "GA": "fr-Latn-GA", "GE": "ka-Geor-GE", "GF": "fr-Latn-GF", "GH": "ak-Latn-GH", "GL": "kl-Latn-GL", "GN": "fr-Latn-GN", "GP": "fr-Latn-GP", "GQ": "es-Latn-GQ", "GR": "el-Grek-GR", "GT": "es-Latn-GT", "GW": "pt-Latn-GW", "HK": "zh-Hant-HK", "HN": "es-Latn-HN", "HR": "hr-Latn-HR", "HT": "ht-Latn-HT", "HU": "hu-Latn-HU", "IC": "es-Latn-IC", "ID": "id-Latn-ID", "IL": "he-Hebr-IL", "IN": "hi-Deva-IN", "IQ": "ar-Arab-IQ", "IR": "fa-Arab-IR", "IS": "is-Latn-IS", "IT": "it-Latn-IT", "JO": "ar-Arab-JO", "JP": "ja-Jpan-JP", "KE": "sw-Latn-KE", "KG": "ky-Cyrl-KG", "KH": "km-Khmr-KH", "KM": "ar-Arab-KM", "KP": "ko-Kore-KP", "KR": "ko-Kore-KR", "KW": "ar-Arab-KW", "KZ": "ru-Cyrl-KZ", "LA": "lo-Laoo-LA", "LB": "ar-Arab-LB", "LI": "de-Latn-LI", "LK": "si-Sinh-LK", "LS": "st-Latn-LS", "LT": "lt-Latn-LT", "LU": "fr-Latn-LU", "LV": "lv-Latn-LV", "LY": "ar-Arab-LY", "MA": "ar-Arab-MA", "MC": "fr-Latn-MC", "MD": "ro-Latn-MD", "ME": "sr-Latn-ME", "MF": "fr-Latn-MF", "MG": "mg-Latn-MG", "MK": "mk-Cyrl-MK", "ML": "bm-Latn-ML", "MM": "my-Mymr-MM", "MN": "mn-Cyrl-MN", "MO": "zh-Hant-MO", "MQ": "fr-Latn-MQ", "MR": "ar-Arab-MR", "MT": "mt-Latn-MT", "MU": "mfe-Latn-MU", "MV": "dv-Thaa-MV", "MX": "es-Latn-MX", "MY": "ms-Latn-MY", "MZ": "pt-Latn-MZ", "NA": "af-Latn-NA", "NC": "fr-Latn-NC", "NE": "ha-Latn-NE", "NI": "es-Latn-NI", "NL": "nl-Latn-NL", "NO": "nb-Latn-NO", "NP": "ne-Deva-NP", "OM": "ar-Arab-OM", "PA": "es-Latn-PA", "PE": "es-Latn-PE", "PF": "fr-Latn-PF", "PG": "tpi-Latn-PG", "PH": "fil-Latn-PH", "PK": "ur-Arab-PK", "PL": "pl-Latn-PL", "PM": "fr-Latn-PM", "PR": "es-Latn-PR", "PS": "ar-Arab-PS", "PT": "pt-Latn-PT", "PW": "pau-Latn-PW", "PY": "gn-Latn-PY", "QA": "ar-Arab-QA", "RE": "fr-Latn-RE", "RO": "ro-Latn-RO", "RS": "sr-Cyrl-RS", "RU": "ru-Cyrl-RU", "RW": "rw-Latn-RW", "SA": "ar-Arab-SA", "SC": "fr-Latn-SC", "SD": "ar-Arab-SD", "SE": "sv-Latn-SE", "SI": "sl-Latn-SI", "SJ": "nb-Latn-SJ", "SK": "sk-Latn-SK", "SL": "kri-Latn-SL", "SM": "it-Latn-SM", "SN": "fr-Latn-SN", "SO": "so-Latn-SO", "SR": "nl-Latn-SR", "SS": "ar-Arab-SS", "ST": "pt-Latn-ST", "SV": "es-Latn-SV", "SY": "ar-Arab-SY", "TD": "fr-Latn-TD", "TF": "fr-Latn-TF", "TG": "fr-Latn-TG", "TH": "th-Thai-TH", "TJ": "tg-Cyrl-TJ", "TK": "tkl-Latn-TK", "TL": "pt-Latn-TL", "TM": "tk-Latn-TM", "TN": "ar-Arab-TN", "TO": "to-Latn-TO", "TR": "tr-Latn-TR", "TV": "tvl-Latn-TV", "TW": "zh-Hant-TW", "TZ": "sw-Latn-TZ", "UA": "uk-Cyrl-UA", "UG": "sw-Latn-UG", "UY": "es-Latn-UY", "UZ": "uz-Latn-UZ", "VA": "it-Latn-VA", "VE": "es-Latn-VE", "VN": "vi-Latn-VN", "VU": "bi-Latn-VU", "WF": "fr-Latn-WF", "WS": "sm-Latn-WS", "XK": "sq-Latn-XK", "YE": "ar-Arab-YE", "YT": "fr-Latn-YT", "ZM": "bem-Latn-ZM", "ZW": "sn-Latn-ZW" }
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
type DTFParameters = ConstructorParameters<typeof Intl.DateTimeFormat>;
|
|
2
|
-
/**
|
|
3
|
-
* Return the localized default timezone for the system. If `timeZoneName` is not supported, return the IANA timezone name.
|
|
4
|
-
* @param dateDateTimeFormatCreator creator fn for Intl.DateTimeFormat
|
|
5
|
-
* @returns default timezone for the system
|
|
6
|
-
*/
|
|
7
|
-
export declare function defaultTimezone(locales?: DTFParameters[0], options?: Pick<Intl.DateTimeFormatOptions, 'timeZoneName'>): string;
|
|
8
|
-
export {};
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { __spreadArray } from "tslib";
|
|
2
|
-
import { memoize, strategies } from '@formatjs/fast-memoize';
|
|
3
|
-
var cache = {};
|
|
4
|
-
function createFastMemoizeCache(store) {
|
|
5
|
-
return {
|
|
6
|
-
create: function () {
|
|
7
|
-
return {
|
|
8
|
-
get: function (key) {
|
|
9
|
-
return store[key];
|
|
10
|
-
},
|
|
11
|
-
set: function (key, value) {
|
|
12
|
-
store[key] = value;
|
|
13
|
-
},
|
|
14
|
-
};
|
|
15
|
-
},
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
var getDateTimeFormat = memoize(function () {
|
|
19
|
-
var _a;
|
|
20
|
-
var args = [];
|
|
21
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
22
|
-
args[_i] = arguments[_i];
|
|
23
|
-
}
|
|
24
|
-
return new ((_a = Intl.DateTimeFormat).bind.apply(_a, __spreadArray([void 0], args, false)))();
|
|
25
|
-
}, {
|
|
26
|
-
cache: createFastMemoizeCache(cache),
|
|
27
|
-
strategy: strategies.variadic,
|
|
28
|
-
});
|
|
29
|
-
var now = Date.now();
|
|
30
|
-
/**
|
|
31
|
-
* Return the localized default timezone for the system. If `timeZoneName` is not supported, return the IANA timezone name.
|
|
32
|
-
* @param dateDateTimeFormatCreator creator fn for Intl.DateTimeFormat
|
|
33
|
-
* @returns default timezone for the system
|
|
34
|
-
*/
|
|
35
|
-
export function defaultTimezone(locales, options) {
|
|
36
|
-
var _a;
|
|
37
|
-
var timeZoneName = options === null || options === void 0 ? void 0 : options.timeZoneName;
|
|
38
|
-
try {
|
|
39
|
-
var dtf = getDateTimeFormat(locales, {
|
|
40
|
-
timeZoneName: options === null || options === void 0 ? void 0 : options.timeZoneName,
|
|
41
|
-
});
|
|
42
|
-
// If there's no `timeZoneName` specified, return the IANA timezone name
|
|
43
|
-
if (!timeZoneName) {
|
|
44
|
-
return dtf.resolvedOptions().timeZone;
|
|
45
|
-
}
|
|
46
|
-
// If `timeZoneName` is specified, return the localized timezone name
|
|
47
|
-
return (((_a = dtf.formatToParts(now).find(function (p) { return p.type === 'timeZoneName'; })) === null || _a === void 0 ? void 0 : _a.value) ||
|
|
48
|
-
'UTC');
|
|
49
|
-
}
|
|
50
|
-
catch (e) {
|
|
51
|
-
return 'UTC';
|
|
52
|
-
}
|
|
53
|
-
}
|
|
@@ -1,241 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"AFG": "AF",
|
|
3
|
-
"ALB": "AL",
|
|
4
|
-
"DZA": "DZ",
|
|
5
|
-
"ASM": "AS",
|
|
6
|
-
"AND": "AD",
|
|
7
|
-
"AGO": "AO",
|
|
8
|
-
"AIA": "AI",
|
|
9
|
-
"ATA": "AQ",
|
|
10
|
-
"ATG": "AG",
|
|
11
|
-
"ARG": "AR",
|
|
12
|
-
"ARM": "AM",
|
|
13
|
-
"ABW": "AW",
|
|
14
|
-
"AUS": "AU",
|
|
15
|
-
"AUT": "AT",
|
|
16
|
-
"AZE": "AZ",
|
|
17
|
-
"BHS": "BS",
|
|
18
|
-
"BHR": "BH",
|
|
19
|
-
"BGD": "BD",
|
|
20
|
-
"BRB": "BB",
|
|
21
|
-
"BLR": "BY",
|
|
22
|
-
"BEL": "BE",
|
|
23
|
-
"BLZ": "BZ",
|
|
24
|
-
"BEN": "BJ",
|
|
25
|
-
"BMU": "BM",
|
|
26
|
-
"BTN": "BT",
|
|
27
|
-
"BOL": "BO",
|
|
28
|
-
"BIH": "BA",
|
|
29
|
-
"BWA": "BW",
|
|
30
|
-
"BRA": "BR",
|
|
31
|
-
"IOT": "IO",
|
|
32
|
-
"BRN": "BN",
|
|
33
|
-
"BGR": "BG",
|
|
34
|
-
"BFA": "BF",
|
|
35
|
-
"BDI": "BI",
|
|
36
|
-
"CPV": "CV",
|
|
37
|
-
"KHM": "KH",
|
|
38
|
-
"CMR": "CM",
|
|
39
|
-
"CAN": "CA",
|
|
40
|
-
"CYM": "KY",
|
|
41
|
-
"CAF": "CF",
|
|
42
|
-
"TCD": "TD",
|
|
43
|
-
"CHL": "CL",
|
|
44
|
-
"CHN": "CN",
|
|
45
|
-
"COL": "CO",
|
|
46
|
-
"COM": "KM",
|
|
47
|
-
"COG": "CG",
|
|
48
|
-
"COD": "CD",
|
|
49
|
-
"COK": "CK",
|
|
50
|
-
"CRI": "CR",
|
|
51
|
-
"CIV": "CI",
|
|
52
|
-
"HRV": "HR",
|
|
53
|
-
"CUB": "CU",
|
|
54
|
-
"CUW": "CW",
|
|
55
|
-
"CYP": "CY",
|
|
56
|
-
"CZE": "CZ",
|
|
57
|
-
"DNK": "DK",
|
|
58
|
-
"DJI": "DJ",
|
|
59
|
-
"DMA": "DM",
|
|
60
|
-
"DOM": "DO",
|
|
61
|
-
"ECU": "EC",
|
|
62
|
-
"EGY": "EG",
|
|
63
|
-
"SLV": "SV",
|
|
64
|
-
"GNQ": "GQ",
|
|
65
|
-
"ERI": "ER",
|
|
66
|
-
"EST": "EE",
|
|
67
|
-
"SWZ": "SZ",
|
|
68
|
-
"ETH": "ET",
|
|
69
|
-
"FLK": "FK",
|
|
70
|
-
"FRO": "FO",
|
|
71
|
-
"FJI": "FJ",
|
|
72
|
-
"FIN": "FI",
|
|
73
|
-
"FRA": "FR",
|
|
74
|
-
"GUF": "GF",
|
|
75
|
-
"PYF": "PF",
|
|
76
|
-
"ATF": "TF",
|
|
77
|
-
"GAB": "GA",
|
|
78
|
-
"GMB": "GM",
|
|
79
|
-
"GEO": "GE",
|
|
80
|
-
"DEU": "DE",
|
|
81
|
-
"GHA": "GH",
|
|
82
|
-
"GIB": "GI",
|
|
83
|
-
"GRC": "GR",
|
|
84
|
-
"GRL": "GL",
|
|
85
|
-
"GRD": "GD",
|
|
86
|
-
"GLP": "GP",
|
|
87
|
-
"GUM": "GU",
|
|
88
|
-
"GTM": "GT",
|
|
89
|
-
"GGY": "GG",
|
|
90
|
-
"GIN": "GN",
|
|
91
|
-
"GNB": "GW",
|
|
92
|
-
"GUY": "GY",
|
|
93
|
-
"HTI": "HT",
|
|
94
|
-
"HND": "HN",
|
|
95
|
-
"HKG": "HK",
|
|
96
|
-
"HUN": "HU",
|
|
97
|
-
"ISL": "IS",
|
|
98
|
-
"IND": "IN",
|
|
99
|
-
"IDN": "ID",
|
|
100
|
-
"IRN": "IR",
|
|
101
|
-
"IRQ": "IQ",
|
|
102
|
-
"IRL": "IE",
|
|
103
|
-
"IMN": "IM",
|
|
104
|
-
"ISR": "IL",
|
|
105
|
-
"ITA": "IT",
|
|
106
|
-
"JAM": "JM",
|
|
107
|
-
"JPN": "JP",
|
|
108
|
-
"JEY": "JE",
|
|
109
|
-
"JOR": "JO",
|
|
110
|
-
"KAZ": "KZ",
|
|
111
|
-
"KEN": "KE",
|
|
112
|
-
"KIR": "KI",
|
|
113
|
-
"PRK": "KP",
|
|
114
|
-
"KOR": "KR",
|
|
115
|
-
"KWT": "KW",
|
|
116
|
-
"KGZ": "KG",
|
|
117
|
-
"LAO": "LA",
|
|
118
|
-
"LVA": "LV",
|
|
119
|
-
"LBN": "LB",
|
|
120
|
-
"LSO": "LS",
|
|
121
|
-
"LBR": "LR",
|
|
122
|
-
"LBY": "LY",
|
|
123
|
-
"LIE": "LI",
|
|
124
|
-
"LTU": "LT",
|
|
125
|
-
"LUX": "LU",
|
|
126
|
-
"MAC": "MO",
|
|
127
|
-
"MDG": "MG",
|
|
128
|
-
"MWI": "MW",
|
|
129
|
-
"MYS": "MY",
|
|
130
|
-
"MDV": "MV",
|
|
131
|
-
"MLI": "ML",
|
|
132
|
-
"MLT": "MT",
|
|
133
|
-
"MHL": "MH",
|
|
134
|
-
"MTQ": "MQ",
|
|
135
|
-
"MRT": "MR",
|
|
136
|
-
"MUS": "MU",
|
|
137
|
-
"MYT": "YT",
|
|
138
|
-
"MEX": "MX",
|
|
139
|
-
"FSM": "FM",
|
|
140
|
-
"MDA": "MD",
|
|
141
|
-
"MCO": "MC",
|
|
142
|
-
"MNG": "MN",
|
|
143
|
-
"MNE": "ME",
|
|
144
|
-
"MSR": "MS",
|
|
145
|
-
"MAR": "MA",
|
|
146
|
-
"MOZ": "MZ",
|
|
147
|
-
"MMR": "MM",
|
|
148
|
-
"NAM": "NA",
|
|
149
|
-
"NRU": "NR",
|
|
150
|
-
"NPL": "NP",
|
|
151
|
-
"NLD": "NL",
|
|
152
|
-
"NCL": "NC",
|
|
153
|
-
"NZL": "NZ",
|
|
154
|
-
"NIC": "NI",
|
|
155
|
-
"NER": "NE",
|
|
156
|
-
"NGA": "NG",
|
|
157
|
-
"NIU": "NU",
|
|
158
|
-
"NFK": "NF",
|
|
159
|
-
"MKD": "MK",
|
|
160
|
-
"MNP": "MP",
|
|
161
|
-
"NOR": "NO",
|
|
162
|
-
"OMN": "OM",
|
|
163
|
-
"PAK": "PK",
|
|
164
|
-
"PLW": "PW",
|
|
165
|
-
"PSE": "PS",
|
|
166
|
-
"PAN": "PA",
|
|
167
|
-
"PNG": "PG",
|
|
168
|
-
"PRY": "PY",
|
|
169
|
-
"PER": "PE",
|
|
170
|
-
"PHL": "PH",
|
|
171
|
-
"PCN": "PN",
|
|
172
|
-
"POL": "PL",
|
|
173
|
-
"PRT": "PT",
|
|
174
|
-
"PRI": "PR",
|
|
175
|
-
"QAT": "QA",
|
|
176
|
-
"REU": "RE",
|
|
177
|
-
"ROU": "RO",
|
|
178
|
-
"RUS": "RU",
|
|
179
|
-
"RWA": "RW",
|
|
180
|
-
"BLM": "BL",
|
|
181
|
-
"SHN": "SH",
|
|
182
|
-
"KNA": "KN",
|
|
183
|
-
"LCA": "LC",
|
|
184
|
-
"MAF": "MF",
|
|
185
|
-
"SPM": "PM",
|
|
186
|
-
"VCT": "VC",
|
|
187
|
-
"WSM": "WS",
|
|
188
|
-
"SMR": "SM",
|
|
189
|
-
"STP": "ST",
|
|
190
|
-
"SAU": "SA",
|
|
191
|
-
"SEN": "SN",
|
|
192
|
-
"SRB": "RS",
|
|
193
|
-
"SYC": "SC",
|
|
194
|
-
"SLE": "SL",
|
|
195
|
-
"SGP": "SG",
|
|
196
|
-
"SXM": "SX",
|
|
197
|
-
"SVK": "SK",
|
|
198
|
-
"SVN": "SI",
|
|
199
|
-
"SLB": "SB",
|
|
200
|
-
"SOM": "SO",
|
|
201
|
-
"ZAF": "ZA",
|
|
202
|
-
"SSD": "SS",
|
|
203
|
-
"ESP": "ES",
|
|
204
|
-
"LKA": "LK",
|
|
205
|
-
"SDN": "SD",
|
|
206
|
-
"SUR": "SR",
|
|
207
|
-
"SJM": "SJ",
|
|
208
|
-
"SWE": "SE",
|
|
209
|
-
"CHE": "CH",
|
|
210
|
-
"SYR": "SY",
|
|
211
|
-
"TWN": "TW",
|
|
212
|
-
"TJK": "TJ",
|
|
213
|
-
"TZA": "TZ",
|
|
214
|
-
"THA": "TH",
|
|
215
|
-
"TLS": "TL",
|
|
216
|
-
"TGO": "TG",
|
|
217
|
-
"TKL": "TK",
|
|
218
|
-
"TON": "TO",
|
|
219
|
-
"TTO": "TT",
|
|
220
|
-
"TUN": "TN",
|
|
221
|
-
"TUR": "TR",
|
|
222
|
-
"TKM": "TM",
|
|
223
|
-
"TCA": "TC",
|
|
224
|
-
"TUV": "TV",
|
|
225
|
-
"UGA": "UG",
|
|
226
|
-
"UKR": "UA",
|
|
227
|
-
"ARE": "AE",
|
|
228
|
-
"GBR": "GB",
|
|
229
|
-
"USA": "US",
|
|
230
|
-
"URY": "UY",
|
|
231
|
-
"UZB": "UZ",
|
|
232
|
-
"VUT": "VU",
|
|
233
|
-
"VEN": "VE",
|
|
234
|
-
"VNM": "VN",
|
|
235
|
-
"VGB": "VG",
|
|
236
|
-
"VIR": "VI",
|
|
237
|
-
"ESH": "EH",
|
|
238
|
-
"YEM": "YE",
|
|
239
|
-
"ZMB": "ZM",
|
|
240
|
-
"ZWE": "ZW"
|
|
241
|
-
}
|
package/lib/src/iso4217.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Returns the minor unit scale for a given currency code.
|
|
3
|
-
*
|
|
4
|
-
* The minor unit scale is the number of decimal places used for the currency.
|
|
5
|
-
* For example, USD has 2 decimal places, so the minor unit scale is 100.
|
|
6
|
-
*
|
|
7
|
-
* @param currencyCode - The ISO 4217 currency code (e.g., 'USD', 'EUR').
|
|
8
|
-
* @returns The minor unit scale as a power of 10.
|
|
9
|
-
*/
|
|
10
|
-
export declare function currencyMinorScale(currencyCode: string): number;
|
package/lib/src/iso4217.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import * as iso4217 from './currencyMinorUnits.generated.json';
|
|
2
|
-
/**
|
|
3
|
-
* Returns the number of minor units (decimal places) for a given currency code.
|
|
4
|
-
*
|
|
5
|
-
* @param currencyCode - The ISO 4217 currency code (e.g., 'USD', 'EUR').
|
|
6
|
-
* @returns The number of minor units for the specified currency.
|
|
7
|
-
* @throws Will throw an error if the currency code is unknown.
|
|
8
|
-
*/
|
|
9
|
-
function currencyMinorUnits(currencyCode) {
|
|
10
|
-
var minorUnits = iso4217[currencyCode.toUpperCase()];
|
|
11
|
-
if (minorUnits == null) {
|
|
12
|
-
throw new Error("Unknown currency code: ".concat(currencyCode));
|
|
13
|
-
}
|
|
14
|
-
return minorUnits;
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Returns the minor unit scale for a given currency code.
|
|
18
|
-
*
|
|
19
|
-
* The minor unit scale is the number of decimal places used for the currency.
|
|
20
|
-
* For example, USD has 2 decimal places, so the minor unit scale is 100.
|
|
21
|
-
*
|
|
22
|
-
* @param currencyCode - The ISO 4217 currency code (e.g., 'USD', 'EUR').
|
|
23
|
-
* @returns The minor unit scale as a power of 10.
|
|
24
|
-
*/
|
|
25
|
-
export function currencyMinorScale(currencyCode) {
|
|
26
|
-
return Math.pow(10, currencyMinorUnits(currencyCode));
|
|
27
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Returns the number of minor units (decimal places) for a given currency code.
|
|
3
|
-
*
|
|
4
|
-
* @param currencyCode - The ISO 4217 currency code (e.g., 'USD', 'EUR').
|
|
5
|
-
* @returns The number of minor units for the specified currency.
|
|
6
|
-
* @throws Will throw an error if the currency code is unknown.
|
|
7
|
-
*/
|
|
8
|
-
export declare function currencyMinorUnits(currencyCode: string): number;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.currencyMinorUnits = currencyMinorUnits;
|
|
4
|
-
var tslib_1 = require("tslib");
|
|
5
|
-
var iso4217 = tslib_1.__importStar(require("./currencyMinorUnits.generated.json"));
|
|
6
|
-
/**
|
|
7
|
-
* Returns the number of minor units (decimal places) for a given currency code.
|
|
8
|
-
*
|
|
9
|
-
* @param currencyCode - The ISO 4217 currency code (e.g., 'USD', 'EUR').
|
|
10
|
-
* @returns The number of minor units for the specified currency.
|
|
11
|
-
* @throws Will throw an error if the currency code is unknown.
|
|
12
|
-
*/
|
|
13
|
-
function currencyMinorUnits(currencyCode) {
|
|
14
|
-
var minorUnits = iso4217[currencyCode.toUpperCase()];
|
|
15
|
-
if (minorUnits == null) {
|
|
16
|
-
throw new Error("Unknown currency code: ".concat(currencyCode));
|
|
17
|
-
}
|
|
18
|
-
return minorUnits;
|
|
19
|
-
}
|