File tree 2 files changed +3
-6
lines changed
2 files changed +3
-6
lines changed Original file line number Diff line number Diff line change 1
1
{
2
- "version" : " 0.1.3 " ,
2
+ "version" : " 0.1.4 " ,
3
3
"name" : " react-phone-hooks" ,
4
4
"description" : " React hooks and utility functions for parsing and validating phone numbers." ,
5
5
"keywords" : [
Original file line number Diff line number Diff line change @@ -10,11 +10,8 @@ const slots = new Set(".");
10
10
11
11
export const getMetadata = ( rawValue : string , countriesList : typeof countries = countries , country : any = null ) => {
12
12
country = country == null && rawValue . startsWith ( "44" ) ? "gb" : country ;
13
- if ( country != null ) {
14
- countriesList = countriesList . filter ( ( c ) => c [ 0 ] === country ) ;
15
- countriesList = countriesList . sort ( ( a , b ) => b [ 2 ] . length - a [ 2 ] . length ) ;
16
- }
17
- return countriesList . find ( ( c ) => rawValue . startsWith ( c [ 2 ] ) ) ;
13
+ if ( country != null ) countriesList = countriesList . filter ( ( c ) => c [ 0 ] === country ) ;
14
+ return [ ...countriesList ] . sort ( ( a , b ) => b [ 2 ] . length - a [ 2 ] . length ) . find ( ( c ) => rawValue . startsWith ( c [ 2 ] ) ) ;
18
15
}
19
16
20
17
export const getCountry = ( countryCode : keyof typeof countries ) => {
You can’t perform that action at this time.
0 commit comments