'use strict';

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

const findCountryByPrefix = number => {
  if (number.length > 1) {
    const matchingCodes = countries.filter(country => number.startsWith(country.phone));
    if (matchingCodes.length > 0) {
      return index.longestMatchingPrefix(matchingCodes);
    }
  }
  return null;
};

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