-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.d.ts
175 lines (163 loc) · 4.4 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
type ArrayHandler<Item, Result> = (
value: Item,
index: number,
array: Item[],
) => Result;
type ArrayReduceHandler<Item, Result> = (
accumulator: Result,
value: Item,
index: number,
array: Item[],
) => Result;
type ObjectHandler<Item, Result> = (
value: Item,
key: string,
object: Record<number | string, Item>,
) => Result;
type ObjectReduceHandler<Item, Result> = (
accumulator?: Result,
value?: Item,
key?: string,
object?: Record<number | string, Item>,
) => Result;
declare function every<Item>(
collection: Item[] | readonly Item[],
handler: ArrayHandler<Item, unknown>,
): boolean;
declare function everyObject<Item>(
collection:
| Record<number | string, Item>
| Readonly<Record<number | string, Item>>,
handler: ObjectHandler<Item, unknown>,
): boolean;
declare function everyRight<Item>(
collection: Item[] | readonly Item[],
handler: ArrayHandler<Item, unknown>,
): boolean;
declare function filter<Item>(
collection: Item[] | readonly Item[],
handler: ArrayHandler<Item, unknown>,
): Item[];
declare function filterObject<Item>(
collection:
| Record<number | string, Item>
| Readonly<Record<number | string, Item>>,
handler: ObjectHandler<Item, unknown>,
): Record<number | string, Item>;
declare function filterRight<Item>(
collection: Item[] | readonly Item[],
handler: ArrayHandler<Item, unknown>,
): Item[];
declare function find<Item>(
collection: Item[] | readonly Item[],
handler: ArrayHandler<Item, unknown>,
): Item | undefined;
declare function findObject<Item>(
collection:
| Record<number | string, Item>
| Readonly<Record<number | string, Item>>,
handler: ObjectHandler<Item, unknown>,
): Item | undefined;
declare function findLast<Item>(
collection: Item[] | readonly Item[],
handler: ArrayHandler<Item, unknown>,
): Item | undefined;
declare function findIndex<Item>(
collection: Item[] | readonly Item[],
handler: ArrayHandler<Item, unknown>,
): number;
declare function findKey<Item>(
collection:
| Record<number | string, Item>
| Readonly<Record<number | string, Item>>,
handler: ObjectHandler<Item, unknown>,
): string | void;
declare function findLastIndex<Item>(
collection: Item[] | readonly Item[],
handler: ArrayHandler<Item, unknown>,
): number;
declare function forEach<Item>(
collection: Item[] | readonly Item[],
handler: ArrayHandler<Item, void>,
): void;
declare function forEachObject<Item>(
collection:
| Record<number | string, Item>
| Readonly<Record<number | string, Item>>,
handler: ObjectHandler<Item, void>,
): void;
declare function forEachRight<Item>(
collection: Item[] | readonly Item[],
handler: ArrayHandler<Item, void>,
): void;
declare function map<Item, Result>(
collection: Item[] | readonly Item[],
handler: ArrayHandler<Item, Result>,
): Result[];
declare function mapObject<Item, Result>(
collection:
| Record<number | string, Item>
| Readonly<Record<number | string, Item>>,
handler: ObjectHandler<Item, Result>,
): Record<number | string, Result>;
declare function mapRight<Item, Result>(
collection: Item[] | readonly Item[],
handler: ArrayHandler<Item, Result>,
): Result[];
declare function reduce<Item, Result>(
collection: Item[] | readonly Item[],
handler: ArrayReduceHandler<Item, Result>,
initialValue?: Result,
): Result;
declare function reduceObject<Item, Result>(
collection:
| Record<number | string, Item>
| Readonly<Record<number | string, Item>>,
handler: ObjectReduceHandler<Item, Result>,
initialValue?: Result,
): Result;
declare function reduceRight<Item, Result>(
collection: Item[] | readonly Item[],
handler: ArrayReduceHandler<Item, Result>,
initialValue?: Result,
): Result;
declare function some<Item>(
collection: Item[] | readonly Item[],
handler: ArrayHandler<Item, unknown>,
): boolean;
declare function someObject<Item>(
collection:
| Record<number | string, Item>
| Readonly<Record<number | string, Item>>,
handler: ObjectHandler<Item, unknown>,
): boolean;
declare function someRight<Item>(
collection: Item[] | readonly Item[],
handler: ArrayHandler<Item, unknown>,
): boolean;
export {
every,
everyObject,
everyRight,
filter,
filterObject,
filterRight,
find,
findIndex,
findLastIndex,
findKey,
findObject,
findLast,
forEach,
forEachObject,
forEachRight,
map,
mapObject,
mapRight,
reduce,
reduceObject,
reduceRight,
some,
someObject,
someRight,
};