Formatting
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { EventEmitter } from '../event-emitter.js';
|
||||
import { EventEmitter } from "../event-emitter.js";
|
||||
|
||||
/**
|
||||
* Events emitted by our Rates Adapters
|
||||
@@ -44,14 +44,15 @@ export abstract class BaseRates<
|
||||
BCH: 8,
|
||||
USD: 2,
|
||||
};
|
||||
const minimumFractionDigits = minimumFractionDigitsMap[normalizedCurrency] ?? 2;
|
||||
const minimumFractionDigits =
|
||||
minimumFractionDigitsMap[normalizedCurrency] ?? 2;
|
||||
const maximumFractionDigits = Math.max(minimumFractionDigits, 8);
|
||||
|
||||
try {
|
||||
const formatter = new Intl.NumberFormat('en-US', {
|
||||
style: 'currency',
|
||||
const formatter = new Intl.NumberFormat("en-US", {
|
||||
style: "currency",
|
||||
currency: normalizedCurrency,
|
||||
currencyDisplay: 'narrowSymbol',
|
||||
currencyDisplay: "narrowSymbol",
|
||||
minimumFractionDigits,
|
||||
maximumFractionDigits,
|
||||
});
|
||||
@@ -61,7 +62,7 @@ export abstract class BaseRates<
|
||||
// Some numerator symbols from oracle pairs (e.g. DOGE/BCH) are not ISO-4217
|
||||
// fiat currency codes, so Intl currency formatting will throw a RangeError.
|
||||
// In that case we still return a human-readable formatted value.
|
||||
const numericFormatter = new Intl.NumberFormat('en-US', {
|
||||
const numericFormatter = new Intl.NumberFormat("en-US", {
|
||||
minimumFractionDigits,
|
||||
maximumFractionDigits,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user