Skip to content

Commit

Permalink
publish/ v1.2.7
Browse files Browse the repository at this point in the history
  • Loading branch information
hendurhance committed Apr 16, 2024
1 parent ef8771f commit 27b6a7e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@amplifiedhq/countries-atlas",
"version": "1.2.6",
"version": "1.2.7",
"description": "Uncover the world with a single lightweight library - countries, codes, currencies, flags, languages, cities, and more 🌎",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down
11 changes: 6 additions & 5 deletions src/helpers/CountriesAtlas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,15 @@ export class CountriesAtlas {
* Retrieve all states of a country by its ISO2 code.
*
* @param {string} iso2 - ISO2 code of the country.
* @returns {State[] | undefined} - Array of state objects or undefined if not found.
* @returns {Promise<State[]> | undefined} - Array of state objects or undefined if not found.
*/
getStates(iso2: string): State[] | undefined {
getStates(iso2: string): Promise<State[]> | undefined {
const country = this.find(iso2)
if (country) {
// eslint-disable-next-line @typescript-eslint/no-var-requires
const statesData = require(`../data/countries/${country.iso2?.toLowerCase()}.json`)
return statesData.states
const stateData = import(`../data/countries/${country.iso2?.toLowerCase()}.json`)
return stateData.then((statesData: StateData) => {
return statesData.states
});
}
return undefined
}
Expand Down

0 comments on commit 27b6a7e

Please sign in to comment.