ConstCURRENCY_CODE_MAP['$'] // returns 'USD'
CURRENCY_CODE_MAP['₹'] // returns 'INR'
export const CURRENCY_CODE_MAP: { [key: string]: string } = Object.entries(CURRENCY_INFO).reduce<{
[key: string]: string;
}>(
(map, [code, { symbol }]) => {
if (!(symbol in map)) {
map[symbol] = code;
}
return map;
},
{ ...CURRENCY_CODE_OVERRIDES },
);
Mapping of currency symbols to their corresponding currency codes. Several currencies share a symbol (e.g. "$" → USD/SRD, "£" → GBP/GIP/…); the library lists the major currency first, so we keep the first code seen for each symbol ("first wins") to resolve "$" → USD, "£" → GBP, "₩" → KRW.