country-seeker
Advanced tools
Comparing version 1.0.4 to 1.0.5
{ | ||
"name": "country-seeker", | ||
"version": "1.0.4", | ||
"version": "1.0.5", | ||
"types": "./types/index.d.ts", | ||
@@ -5,0 +5,0 @@ "description": "Get comprehensive country details with ease using country data", |
@@ -20,15 +20,47 @@ | ||
export const useDialCode = ({ type }: { type: IType }) => { | ||
export const useCountry = ({ type, value }: { type: IType, value: string }) => { | ||
if(!value) { | ||
return countryData; | ||
} | ||
switch(type){ | ||
case types.code: | ||
return countryData.find((e) => e.code === type); | ||
return countryData.filter((e) => e.code === value)[0]; | ||
case types.dial_code: | ||
return countryData.find((e) => e.dial_code === type); | ||
return countryData.filter((e) => e.dial_code === value)[0]; | ||
case types.flag: | ||
return countryData.find((e) => e.flag === type); | ||
return countryData.filter((e) => e.flag === value)[0]; | ||
case types.name: | ||
return countryData.find((e) => e.name === type); | ||
return countryData.filter((e) => e.name === value)[0]; | ||
default: | ||
return null; | ||
} | ||
}; | ||
export const useDialCode = ({ value }: { value: string }) => { | ||
if(!value) { | ||
return countryData; | ||
} | ||
return countryData.filter((e) => e.dial_code === value)[0]; | ||
}; | ||
export const useFlag = ({ value }: { value: string }) => { | ||
if(!value) { | ||
return countryData; | ||
} | ||
return countryData.filter((e) => e.flag === value)[0]; | ||
}; | ||
export const useCountryName = ({ value }: { value: string }) => { | ||
if(!value) { | ||
return countryData; | ||
} | ||
return countryData.filter((e) => e.name === value)[0]; | ||
}; | ||
export const useCountryCode = ({ value }: { value: string }) => { | ||
if(!value) { | ||
return countryData; | ||
} | ||
return countryData.filter((e) => e.code === value)[0]; | ||
}; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
22832
105