Simple function that returns the ISO 3166-1 alpha-3 country code of the country where you are geolocated.
The implementation wraps the HTML5 navigator.geolocation.getCurrentPosition function in a promise and uses the which-country lib in order to retrieve a country from its coords.
You can handle errors with a callback param :
Position options are also accepted :
MIT © Alexis Kofman