@aerapass/country-data
Version:
Data about countries - like their ISO codes and currencies
59 lines • 2.38 kB
JavaScript
;
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.languages = exports.currencies = exports.countries = void 0;
/* eslint-disable @typescript-eslint/no-var-requires */
const _ = require("underscore");
__exportStar(require("./continents"), exports);
__exportStar(require("./regions"), exports);
const countriesAll = require('../data/countries.json');
const currenciesAll = require('../data/currencies.json');
const languagesAll = require('../data/languages.json');
const getSymbol = require('currency-symbol-map');
exports.countries = {
all: countriesAll,
};
exports.currencies = {
all: currenciesAll,
};
_.each(countriesAll, (country) => {
// prefer assigned country codes over inactive ones
const exportedAlpha2 = exports.countries[country.alpha2];
if (!exportedAlpha2 || exportedAlpha2.status === 'deleted') {
exports.countries[country.alpha2] = country;
}
const exportedAlpha3 = exports.countries[country.alpha3];
if (!exportedAlpha3 || exportedAlpha3.status === 'deleted') {
exports.countries[country.alpha3] = country;
}
});
_.each(currenciesAll, (currency) => {
//If the symbol isn't available, default to the currency code
let symbol = getSymbol(currency.code);
if (symbol == '?') {
symbol = currency.code;
}
currency.symbol = symbol;
exports.currencies[currency.code] = currency;
});
exports.languages = {
all: languagesAll,
};
// Note that for the languages there are several entries with the same alpha3 -
// eg Dutch and Flemish. Not sure how to best deal with that - here whichever
// comes last wins.
_.each(languagesAll, (language) => {
exports.languages[language.alpha2] = language;
exports.languages[language.bibliographic] = language;
exports.languages[language.alpha3] = language;
});
//# sourceMappingURL=index.js.map