text-country
v0.1.2
Published
Finds country in text
Downloads
67
Maintainers
Readme
text-country
Finds country in text.
Usage
import textCountry from 'text-country';
const lang = 'en';
const text = 'Ministry of Foreign Affairs of Moldova'; // Moldova => md
const results = textCountry(text, lang);
// [{ "country": "md", "rating": 1 }]
API
(text: string, lang: string, options?: Options): CountryRating[]
Returns a list of founded countries ordered by rating.
TS Types
type Options = {
// returns first found country
firstFound?: boolean
}
type CountryRating = {
country: string
rating: number
}