'use strict';

var countries = require('../../data/countries.js');
var index = require('../longestMatchingPrefix/index.js');

const findCountryByCode = code => {
  if (code.length === 2) {
    const matchingCodes = countries.filter(country => code.toUpperCase() === country.iso2);
    if (matchingCodes.length > 0) {
      return index.longestMatchingPrefix(matchingCodes);
    }
  }
  return null;
};

exports.findCountryByCode = findCountryByCode;
//# sourceMappingURL=index.js.map
