File tree Expand file tree Collapse file tree 2 files changed +3
-6
lines changed Expand file tree Collapse file tree 2 files changed +3
-6
lines changed Original file line number Diff line number Diff line change 11{
2- "version" : " 0.1.3 " ,
2+ "version" : " 0.1.4 " ,
33 "name" : " react-phone-hooks" ,
44 "description" : " React hooks and utility functions for parsing and validating phone numbers." ,
55 "keywords" : [
Original file line number Diff line number Diff line change @@ -10,11 +10,8 @@ const slots = new Set(".");
1010
1111export const getMetadata = ( rawValue : string , countriesList : typeof countries = countries , country : any = null ) => {
1212 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 ] ) ) ;
1815}
1916
2017export const getCountry = ( countryCode : keyof typeof countries ) => {
You can’t perform that action at this time.
0 commit comments