Skip to content

mitica/text-country

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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
}