country-mobile-number-validator
Version:
A lightweight Javascript library for retrieving country information, including country codes, based on provided data. Simplify your application's logic by seamlessly integrating with this package to extract essential country details, facilitating tasks su
10 lines (7 loc) • 390 B
JavaScript
const fs = require('fs');
const path = require('path');
const countriesData = JSON.parse(fs.readFileSync(path.join(__dirname, 'mobileNumberLengthByCountry.json'), 'utf8'));
const getCountryByCode = (countryCode) => {
return countriesData.find(country => country.phoneNumberLengthByCountry_CountryCode === countryCode) || null;
};
module.exports = { getCountryByCode };