@formatjs/utils 1.8.3 → 1.9.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/index.d.ts +1 -0
- package/index.js +3 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.js +1 -0
- package/lib/src/currencyMinorUnits.d.ts +8 -0
- package/lib/src/currencyMinorUnits.generated.json +1 -0
- package/lib/src/currencyMinorUnits.js +15 -0
- package/package.json +5 -2
- package/src/currencyMinorUnits.d.ts +8 -0
- package/src/currencyMinorUnits.generated.json +1 -0
- package/src/currencyMinorUnits.js +19 -0
package/index.d.ts
CHANGED
|
@@ -2,3 +2,4 @@ export { canonicalizeCountryCode } from './src/countryCodes';
|
|
|
2
2
|
export { countriesUsingDefaultCurrency, defaultCurrency, } from './src/defaultCurrency';
|
|
3
3
|
export { defaultLocale } from './src/defaultLocale';
|
|
4
4
|
export { defaultTimezone } from './src/defaultTimezone';
|
|
5
|
+
export { currencyMinorUnits } from './src/currencyMinorUnits';
|
package/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.defaultTimezone = exports.defaultLocale = exports.defaultCurrency = exports.countriesUsingDefaultCurrency = exports.canonicalizeCountryCode = void 0;
|
|
3
|
+
exports.currencyMinorUnits = exports.defaultTimezone = exports.defaultLocale = exports.defaultCurrency = exports.countriesUsingDefaultCurrency = exports.canonicalizeCountryCode = void 0;
|
|
4
4
|
var countryCodes_1 = require("./src/countryCodes");
|
|
5
5
|
Object.defineProperty(exports, "canonicalizeCountryCode", { enumerable: true, get: function () { return countryCodes_1.canonicalizeCountryCode; } });
|
|
6
6
|
var defaultCurrency_1 = require("./src/defaultCurrency");
|
|
@@ -10,3 +10,5 @@ var defaultLocale_1 = require("./src/defaultLocale");
|
|
|
10
10
|
Object.defineProperty(exports, "defaultLocale", { enumerable: true, get: function () { return defaultLocale_1.defaultLocale; } });
|
|
11
11
|
var defaultTimezone_1 = require("./src/defaultTimezone");
|
|
12
12
|
Object.defineProperty(exports, "defaultTimezone", { enumerable: true, get: function () { return defaultTimezone_1.defaultTimezone; } });
|
|
13
|
+
var currencyMinorUnits_1 = require("./src/currencyMinorUnits");
|
|
14
|
+
Object.defineProperty(exports, "currencyMinorUnits", { enumerable: true, get: function () { return currencyMinorUnits_1.currencyMinorUnits; } });
|
package/lib/index.d.ts
CHANGED
|
@@ -2,3 +2,4 @@ export { canonicalizeCountryCode } from './src/countryCodes';
|
|
|
2
2
|
export { countriesUsingDefaultCurrency, defaultCurrency, } from './src/defaultCurrency';
|
|
3
3
|
export { defaultLocale } from './src/defaultLocale';
|
|
4
4
|
export { defaultTimezone } from './src/defaultTimezone';
|
|
5
|
+
export { currencyMinorUnits } from './src/currencyMinorUnits';
|
package/lib/index.js
CHANGED
|
@@ -2,3 +2,4 @@ export { canonicalizeCountryCode } from './src/countryCodes';
|
|
|
2
2
|
export { countriesUsingDefaultCurrency, defaultCurrency, } from './src/defaultCurrency';
|
|
3
3
|
export { defaultLocale } from './src/defaultLocale';
|
|
4
4
|
export { defaultTimezone } from './src/defaultTimezone';
|
|
5
|
+
export { currencyMinorUnits } from './src/currencyMinorUnits';
|
|
@@ -0,0 +1,8 @@
|
|
|
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;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{ "AFN": 2, "EUR": 2, "ALL": 2, "DZD": 2, "USD": 2, "AOA": 2, "XCD": 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, "ANG": 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 }
|
|
@@ -0,0 +1,15 @@
|
|
|
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
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@formatjs/utils",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.9.0",
|
|
4
4
|
"description": "Collection of useful intl utilities",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"module": "lib/index.js",
|
|
@@ -22,6 +22,9 @@
|
|
|
22
22
|
"homepage": "https://github.com/formatjs/formatjs#readme",
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"tslib": "2",
|
|
25
|
-
"@formatjs/fast-memoize": "2.2.
|
|
25
|
+
"@formatjs/fast-memoize": "2.2.6"
|
|
26
|
+
},
|
|
27
|
+
"devDependencies": {
|
|
28
|
+
"fast-xml-parser": "^4.5.1"
|
|
26
29
|
}
|
|
27
30
|
}
|
|
@@ -0,0 +1,8 @@
|
|
|
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;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"AFN":2,"EUR":2,"ALL":2,"DZD":2,"USD":2,"AOA":2,"XCD":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,"ANG":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}
|
|
@@ -0,0 +1,19 @@
|
|
|
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
|
+
}
|