index.js
function getCountryByNameOrShortName(name, useAlias) {
  if (!_.isString(name)) return undefined;

  return _.find(countries, (country) => {
    if (useAlias) {
      return country.name.toUpperCase() === name.toUpperCase()
        || country.alpha2.toUpperCase() === name.toUpperCase()
        ||  _.find(country.alias, (alias) => (alias.toUpperCase() === name.toUpperCase()));
    }
    return country.name.toUpperCase() === name.toUpperCase() || country.alpha2.toUpperCase() === name.toUpperCase();
  });
}
function getCountryByNameOrShortName(name, useAlias) {
  if (!_.isString(name)) return undefined;

  return _.find(countries, (country) => {
    if (useAlias) {
      return country.name.toUpperCase() === name.toUpperCase()
        || country.alpha2.toUpperCase() === name.toUpperCase()
        ||  _.find(country.alias, (alias) => (alias.toUpperCase() === name.toUpperCase()));
    }
    return country.name.toUpperCase() === name.toUpperCase() || country.alpha2.toUpperCase() === name.toUpperCase();
  });
}
function getCountryByNameOrShortName ( name , useAlias ) { if ( ! _ . isString ( name ) ) return undefined ; return _ . find ( countries , ( country ) => { if ( useAlias ) { return country . name . toUpperCase ( ) === name . toUpperCase ( ) || country . alpha2 . toUpperCase ( ) === name . toUpperCase ( ) || _ . find ( country . alias , ( alias ) => ( alias . toUpperCase ( ) === name . toUpperCase ( ) ) ) ; } return country . name . toUpperCase ( ) === name . toUpperCase ( ) || country . alpha2 . toUpperCase ( ) === name . toUpperCase ( ) ; } ) ; }
Find the country object of the given country name or short name

@param {String}  name              country name or short name (alpha2)
@param {Boolean} [useAlias]        use alias flag, default `false`
@return {Object} country           country object
Find the country object of the given country name or short name