Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const extractCurrencyDataForLocale = async locale => {
// Get the list of all currencies.
// NOTE: this list contains "old" currencies that are not in used anymore.
const currencyInfo = cldr.extractCurrencyInfoById(locale);
// Fetch list of currencies that are still in use, then use this list
// to "remove" the outdated currencies from the previous list.
const activeCurrencies = await fetch(
'http://www.localeplanet.com/api/auto/currencymap.json'
).then(response => response.json());
return Promise.resolve(
Object.keys(activeCurrencies).reduce(
(acc, key) =>
// `currencyInfo` given by `cldr` may not contain any information based on the
// currencyCode that we fetched from `currencymap.json`, so we have this definition
// check in place.
currencyInfo[key]
? Object.assign({}, acc, {
[key]: {
label: currencyInfo[key].displayName,