Feature request: expose a function to convert CountryCallingCode to CountryCode, or expose MetadataJson value
See original GitHub issueThere is a function exposed getCountryCallingCode(countryCode: CountryCode): CountryCallingCode)
but no inverse of this function:
export function getAllCountryCodes(countryCallingCode: CountryCallingCode): CountryCode[] | undefined {
return metadata.country_calling_codes[countryCallingCode];
}
This would be useful if you are trying to use any of the functionality that uses CountryCode
but your dataset happens to have a calling code separate from the numbers but no country data.
Alternatively exposing the built in metadata would allow users to do this ourselves. An implementation I am playing with today needs this function in order to figure out which parameters are needed to pass to parsePhoneNumber to handle a large amount of questionably formatted data. I’ve resorted to:
const phoneMetadata: Record<string, any> = new Metadata();
let metadataJson: MetadataJson | undefined = undefined;
if ('metadata' in phoneMetadata) {
metadataJson = phoneMetadata.metadata;
}
if (!metadataJson) {
throw new Error(
'libphonenumber-js implementation changed; figure out new way to get country codes from country calling codes'
);
}
to write the above function…
Issue Analytics
- State:
- Created 2 years ago
- Comments:9 (6 by maintainers)
Top Results From Across the Web
Issues · catamphetamine/libphonenumber-js - GitHub
Feature request : expose a function to convert CountryCallingCode to CountryCode, or expose MetadataJson value. #420 opened on Feb 3 by bbarry.
Read more >How I Translate Feature Requests into Code - Michael-F-Bryan
In this stage you develop a big picture view of the feature and how it will expose its functionality to the outside world....
Read more >https://raw.githubusercontent.com/liferay/liferay-...
REQUEST_ADMINISTRATOR_ACCESS=Request Administrator Access (Automatic Copy) action. ... -feature=Add formulas to calculate values based on other fields.
Read more >[Flexible Layouts] Add a render test - Nasa/Openmct - IssueHint
Feature request : expose a function to convert CountryCallingCode to CountryCode, or expose MetadataJson value, 1, 2022-02-03, 2022-08-15.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I think he meant for cases like multiple countries for one country calling code we need a function to extract those countries (that’s my case).
Example for country calling code +44, we could have a function like this:
const countryList = libPhoneNumber.getCountriesByCallingCode(44)
And in countryList we would have :
['GB', 'GG', 'IM', 'JE']
If a phone number belongs to any country, its ‘country’ will be set. Otherwise, the country is unknown
On Wed, 21 Dec 2022 at 23:23, rwev @.***> wrote: