Skip to content

Commit

Permalink
exported types
Browse files Browse the repository at this point in the history
  • Loading branch information
muratgozel committed Aug 19, 2024
1 parent 392f1c2 commit 5b0f8ff
Show file tree
Hide file tree
Showing 10 changed files with 55 additions and 59 deletions.
2 changes: 1 addition & 1 deletion dist/index.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,5 @@ exports.languages = j;
exports.subdivisions = z;
exports.territories = A;
exports.timezones = n;
//# sourceMappingURL=out.js.map
//# sourceMappingURL=index.cjs.map
//# sourceMappingURL=index.cjs.map
2 changes: 1 addition & 1 deletion dist/index.cjs.map

Large diffs are not rendered by default.

37 changes: 16 additions & 21 deletions dist/index.d.cts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ interface Subdivision {
}

declare const countryCodes: string[];
declare const countries: Country[];
declare const countries: LocaleUtilCountry[];
declare const countryCallingCodes: {
AC: number;
AD: number;
Expand Down Expand Up @@ -527,10 +527,10 @@ declare const countryLanguages: {
ZW: string[];
};
declare const currencyCodes: string[];
declare const currencies: Currency[];
declare const currencies: LocaleUtilCurrency[];
declare const languageCodes: string[];
declare const languages: Language[];
declare const timezones: Timezone[];
declare const languages: LocaleUtilLanguage[];
declare const timezones: LocaleUtilTimezone[];
declare const countryCurrencies: {
AC: string;
AD: string;
Expand Down Expand Up @@ -826,17 +826,7 @@ declare const countriesByTerritory: {
"034": string[];
QO: string[];
};
declare const subdivisions: ({
code: string;
countryCode: string;
englishName: string;
nativeName: string;
} | {
code: string;
countryCode: string;
englishName: string;
nativeName?: never;
})[];
declare const subdivisions: LocaleUtilSubdivision[];
declare const findTerritories: () => {
code: string;
name: string;
Expand All @@ -846,17 +836,22 @@ declare const findCountryTerritory: (v: string) => {
name: string;
} | undefined;
declare const isCountryCode: (v: unknown) => boolean;
declare const findCountry: (v: string) => Country | undefined;
declare const findCountry: (v: string) => LocaleUtilCountry | undefined;
declare const findCountryCallingCode: (v: string) => number | undefined;
declare const findCountryLanguages: (v: string) => string[] | undefined;
declare const isCurrencyCode: (v: unknown) => boolean;
declare const findCurrency: (v: string) => Currency | undefined;
declare const findCurrency: (v: string) => LocaleUtilCurrency | undefined;
declare const findCountryCurrencyCode: (v: string) => string | undefined;
declare const isLanguageCode: (v: unknown) => boolean;
declare const findLanguage: (v: string) => Language | undefined;
declare const findCountryTimezones: (v: string) => Timezone[] | undefined;
declare const findLanguage: (v: string) => LocaleUtilLanguage | undefined;
declare const findCountryTimezones: (v: string) => LocaleUtilTimezone[] | undefined;
declare const findCountryFromTimezoneName: (n: string) => string | undefined;
declare const findTimezoneOffset: (v: string) => number | undefined;
declare const findCountrySubdivisions: (v: string) => Subdivision[];
declare const findCountrySubdivisions: (v: string) => LocaleUtilSubdivision[];
type LocaleUtilCountry = Country;
type LocaleUtilCurrency = Currency;
type LocaleUtilLanguage = Language;
type LocaleUtilTimezone = Timezone;
type LocaleUtilSubdivision = Subdivision;

export { countries, countriesByTerritory, countryCallingCodes, countryCodes, countryCurrencies, countryLanguages, currencies, currencyCodes, findCountry, findCountryCallingCode, findCountryCurrencyCode, findCountryFromTimezoneName, findCountryLanguages, findCountrySubdivisions, findCountryTerritory, findCountryTimezones, findCurrency, findLanguage, findTerritories, findTimezoneOffset, isCountryCode, isCurrencyCode, isLanguageCode, languageCodes, languages, subdivisions, territories, timezones };
export { type LocaleUtilCountry, type LocaleUtilCurrency, type LocaleUtilLanguage, type LocaleUtilSubdivision, type LocaleUtilTimezone, countries, countriesByTerritory, countryCallingCodes, countryCodes, countryCurrencies, countryLanguages, currencies, currencyCodes, findCountry, findCountryCallingCode, findCountryCurrencyCode, findCountryFromTimezoneName, findCountryLanguages, findCountrySubdivisions, findCountryTerritory, findCountryTimezones, findCurrency, findLanguage, findTerritories, findTimezoneOffset, isCountryCode, isCurrencyCode, isLanguageCode, languageCodes, languages, subdivisions, territories, timezones };
37 changes: 16 additions & 21 deletions dist/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ interface Subdivision {
}

declare const countryCodes: string[];
declare const countries: Country[];
declare const countries: LocaleUtilCountry[];
declare const countryCallingCodes: {
AC: number;
AD: number;
Expand Down Expand Up @@ -527,10 +527,10 @@ declare const countryLanguages: {
ZW: string[];
};
declare const currencyCodes: string[];
declare const currencies: Currency[];
declare const currencies: LocaleUtilCurrency[];
declare const languageCodes: string[];
declare const languages: Language[];
declare const timezones: Timezone[];
declare const languages: LocaleUtilLanguage[];
declare const timezones: LocaleUtilTimezone[];
declare const countryCurrencies: {
AC: string;
AD: string;
Expand Down Expand Up @@ -826,17 +826,7 @@ declare const countriesByTerritory: {
"034": string[];
QO: string[];
};
declare const subdivisions: ({
code: string;
countryCode: string;
englishName: string;
nativeName: string;
} | {
code: string;
countryCode: string;
englishName: string;
nativeName?: never;
})[];
declare const subdivisions: LocaleUtilSubdivision[];
declare const findTerritories: () => {
code: string;
name: string;
Expand All @@ -846,17 +836,22 @@ declare const findCountryTerritory: (v: string) => {
name: string;
} | undefined;
declare const isCountryCode: (v: unknown) => boolean;
declare const findCountry: (v: string) => Country | undefined;
declare const findCountry: (v: string) => LocaleUtilCountry | undefined;
declare const findCountryCallingCode: (v: string) => number | undefined;
declare const findCountryLanguages: (v: string) => string[] | undefined;
declare const isCurrencyCode: (v: unknown) => boolean;
declare const findCurrency: (v: string) => Currency | undefined;
declare const findCurrency: (v: string) => LocaleUtilCurrency | undefined;
declare const findCountryCurrencyCode: (v: string) => string | undefined;
declare const isLanguageCode: (v: unknown) => boolean;
declare const findLanguage: (v: string) => Language | undefined;
declare const findCountryTimezones: (v: string) => Timezone[] | undefined;
declare const findLanguage: (v: string) => LocaleUtilLanguage | undefined;
declare const findCountryTimezones: (v: string) => LocaleUtilTimezone[] | undefined;
declare const findCountryFromTimezoneName: (n: string) => string | undefined;
declare const findTimezoneOffset: (v: string) => number | undefined;
declare const findCountrySubdivisions: (v: string) => Subdivision[];
declare const findCountrySubdivisions: (v: string) => LocaleUtilSubdivision[];
type LocaleUtilCountry = Country;
type LocaleUtilCurrency = Currency;
type LocaleUtilLanguage = Language;
type LocaleUtilTimezone = Timezone;
type LocaleUtilSubdivision = Subdivision;

export { countries, countriesByTerritory, countryCallingCodes, countryCodes, countryCurrencies, countryLanguages, currencies, currencyCodes, findCountry, findCountryCallingCode, findCountryCurrencyCode, findCountryFromTimezoneName, findCountryLanguages, findCountrySubdivisions, findCountryTerritory, findCountryTimezones, findCurrency, findLanguage, findTerritories, findTimezoneOffset, isCountryCode, isCurrencyCode, isLanguageCode, languageCodes, languages, subdivisions, territories, timezones };
export { type LocaleUtilCountry, type LocaleUtilCurrency, type LocaleUtilLanguage, type LocaleUtilSubdivision, type LocaleUtilTimezone, countries, countriesByTerritory, countryCallingCodes, countryCodes, countryCurrencies, countryLanguages, currencies, currencyCodes, findCountry, findCountryCallingCode, findCountryCurrencyCode, findCountryFromTimezoneName, findCountryLanguages, findCountrySubdivisions, findCountryTerritory, findCountryTimezones, findCurrency, findLanguage, findTerritories, findTimezoneOffset, isCountryCode, isCurrencyCode, isLanguageCode, languageCodes, languages, subdivisions, territories, timezones };
2 changes: 1 addition & 1 deletion dist/index.global.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.global.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "locale-util",
"version": "4.4.0",
"version": "4.5.0",
"description": "Locale data generators written in node.js. Uses reliable sources. Generated data available as JS/JSON objects.",
"type": "module",
"exports": {
Expand Down
26 changes: 16 additions & 10 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,18 @@ import {default as _countriesByTerritory} from './data/countriesByTerritory.json
import {default as _subdivisions} from './data/subdivisions.json'

export const countryCodes: string[] = _countryCodes
export const countries: Country[] = _countries
export const countries: LocaleUtilCountry[] = _countries
export const countryCallingCodes = _countryCallingCodes
export const countryLanguages = _countryLanguages
export const currencyCodes = _currencyCodes
export const currencies: Currency[] = _currencies
export const currencies: LocaleUtilCurrency[] = _currencies
export const languageCodes = _languageCodes
export const languages: Language[] = _languages
export const timezones: Timezone[] = _timezones
export const languages: LocaleUtilLanguage[] = _languages
export const timezones: LocaleUtilTimezone[] = _timezones
export const countryCurrencies = _countryCurrencies
export const territories: { code: string, name: string }[] = _territories
export const countriesByTerritory = _countriesByTerritory
export const subdivisions = _subdivisions
export const subdivisions: LocaleUtilSubdivision[] = _subdivisions

export const findTerritories = () => {
return territories
Expand All @@ -45,7 +45,7 @@ export const isCountryCode = (v: unknown): boolean => {
return typeof v === 'string' && countryCodes.includes(v)
}

export const findCountry = (v: string): Country | undefined => {
export const findCountry = (v: string): LocaleUtilCountry | undefined => {
return countries.find(({code}) => code === v)
}

Expand All @@ -61,7 +61,7 @@ export const isCurrencyCode = (v: unknown): boolean => {
return typeof v === 'string' && currencyCodes.includes(v)
}

export const findCurrency = (v: string): Currency | undefined => {
export const findCurrency = (v: string): LocaleUtilCurrency | undefined => {
return currencies.find(({code}) => code === v)
}

Expand All @@ -73,11 +73,11 @@ export const isLanguageCode = (v: unknown): boolean => {
return typeof v === 'string' && languageCodes.includes(v)
}

export const findLanguage = (v: string): Language | undefined => {
export const findLanguage = (v: string): LocaleUtilLanguage | undefined => {
return languages.find(({code}) => code === v)
}

export const findCountryTimezones = (v: string): Timezone[] | undefined => {
export const findCountryTimezones = (v: string): LocaleUtilTimezone[] | undefined => {
return isCountryCode(v) && timezones.some(({country}) => country === v)
? timezones.filter(({country}) => country === v)
: undefined
Expand All @@ -93,6 +93,12 @@ export const findTimezoneOffset = (v: string): number | undefined => {
: undefined
}

export const findCountrySubdivisions = (v: string): Subdivision[] => {
export const findCountrySubdivisions = (v: string): LocaleUtilSubdivision[] => {
return subdivisions.filter((d) => d.countryCode === v)
}

export type LocaleUtilCountry = Country
export type LocaleUtilCurrency = Currency
export type LocaleUtilLanguage = Language
export type LocaleUtilTimezone = Timezone
export type LocaleUtilSubdivision = Subdivision

0 comments on commit 5b0f8ff

Please sign in to comment.