UNPKG

country-codes-library

Version:

The Country Code Library provides a collection of two-letter and three-letter country codes according to the ISO 3166-1 standard, as well as it provides USA, China and Canada Province codes (State codes / adminstrative division codes). In addition, it inc

40 lines (39 loc) 1.6 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.CountryData = void 0; exports.getAllCountries = getAllCountries; exports.getAllCountryNames = getAllCountryNames; const twoLetterISORegionCode_1 = require("./twoLetterISORegionCode"); const threeLetterISORegionCode_1 = require("./threeLetterISORegionCode"); const countryCallingCodes_1 = require("./countryCallingCodes"); const countryCurrencyCodes_1 = require("./countryCurrencyCodes"); const countryCurrencySymbols_1 = require("./countryCurrencySymbols"); const countryNames_1 = require("./countryNames"); /** * Unified country data combining all available information */ exports.CountryData = {}; // Build the unified country data from existing constants for (const countryName in twoLetterISORegionCode_1.TwoLetterISORegionCode) { const name = countryName; exports.CountryData[countryName] = { name: countryNames_1.CountryNames[countryName] || countryName, code2: twoLetterISORegionCode_1.TwoLetterISORegionCode[name] || '', code3: threeLetterISORegionCode_1.ThreeLetterISORegionCode[name] || '', callingCode: countryCallingCodes_1.CountryCallingCodes[name] || '', currencyCode: countryCurrencyCodes_1.CountryCurrencyCodes[name] || '', currencySymbol: countryCurrencySymbols_1.CountryCurrencySymbols[name] || '', }; } /** * Get all countries as an array */ function getAllCountries() { return Object.values(exports.CountryData); } /** * Get all country names */ function getAllCountryNames() { return Object.keys(exports.CountryData); }