-
Notifications
You must be signed in to change notification settings - Fork 48
/
Copy pathindex.d.ts
67 lines (58 loc) · 1.94 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
// Types for https://www.npmjs.com/package/country-codes-list
// by jakeisnt, Feb. 2022
declare module 'country-codes-list' {
export enum CountryProperty {
countryNameEn = 'countryNameEn',
countryNameLocal = 'countryNameLocal',
countryCode = 'countryCode',
currencyCode = 'currencyCode',
currencyNameEn = 'currencyNameEn',
tinType = 'tinType',
tinName = 'tinName',
officialLanguageCode = 'officialLanguageCode',
officialLanguageNameEn = 'officialLanguageNameEn',
officialLanguageNameLocal = 'officialLanguageNameLocal',
countryCallingCode = 'countryCallingCode',
region = 'region',
flag = 'flag',
}
type CountryData = {
[CountryProperty.countryNameEn]: string
[CountryProperty.countryNameLocal]: string
[CountryProperty.countryCode]: string
[CountryProperty.currencyCode]: string
[CountryProperty.currencyNameEn]: string
[CountryProperty.tinType]: string
[CountryProperty.tinName]: string
[CountryProperty.officialLanguageCode]: string
[CountryProperty.officialLanguageNameEn]: string
[CountryProperty.officialLanguageNameLocal]: string
[CountryProperty.countryCallingCode]: string
[CountryProperty.region]: string
[CountryProperty.flag]: string
}
type Filter<T> = (element: T, index: number, array: T[]) => T[]
type CustomArraySettings = {
sortDataBy?: CountryProperty
sortBy?: any
filter?: Filter<CountryData>
}
export function all(): CountryData[]
export function filter(
countryProperty: CountryProperty,
value: string,
): CountryData[]
export function findOne(
countryProperty: CountryProperty,
value: string,
): CountryData
export function customArray(
fields?: Record<string, string>,
settings?: CustomArraySettings,
): Record<string, string>[]
export function customList(
key?: CountryProperty,
label?: string,
settings?: CustomArraySettings,
): { [key in CountryProperty]: string }
}