Skip to content

Commit

Permalink
fix: update filterByCodes()
Browse files Browse the repository at this point in the history
  • Loading branch information
MagnumGoYB committed Mar 17, 2024
1 parent 34bb0dc commit 01cae09
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
File renamed without changes.
13 changes: 9 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import CountryCodeJson from './countrycode.org.json'
import CountryCodeJson from './country-code.org.json'

export interface CountryNoteType {
code: string
Expand Down Expand Up @@ -50,9 +50,14 @@ export const filterByCodes = (
codes: Array<CountryNoteType['code']>,
iso3?: boolean
) => {
return countryCodes.filter((country) =>
codes.includes(iso3 ? country.ISO3 : country.ISO2)
)
const result = [] as CountryNoteType[]
codes.forEach((code) => {
const country = findByCode(code, iso3)
if (country) {
result.push(country)
}
})
return result
}

export const excludeByNames = (names: Array<CountryNoteType['name']>) => {
Expand Down

0 comments on commit 01cae09

Please sign in to comment.