UNPKG

64 kBTypeScriptView Raw
1import _ = require("../index");
2declare module "../index" {
3 interface LoDashStatic {
4 /**
5 * The opposite of _.before; this method creates a function that invokes func once it’s called n or more times.
6 *
7 * @param n The number of calls before func is invoked.
8 * @param func The function to restrict.
9 * @return Returns the new restricted function.
10 */
11 after<TFunc extends (...args: any[]) => any>(n: number, func: TFunc): TFunc;
12 }
13 interface Primitive<T> {
14 /**
15 * @see _.after
16 */
17 after<TFunc extends (...args: any[]) => any>(func: TFunc): Function<TFunc>;
18 }
19 interface PrimitiveChain<T> {
20 /**
21 * @see _.after
22 */
23 after<TFunc extends (...args: any[]) => any>(func: TFunc): FunctionChain<TFunc>;
24 }
25 interface LoDashStatic {
26 /**
27 * Creates a function that accepts up to n arguments ignoring any additional arguments.
28 *
29 * @param func The function to cap arguments for.
30 * @param n The arity cap.
31 * @returns Returns the new function.
32 */
33 ary(func: (...args: any[]) => any, n?: number): (...args: any[]) => any;
34 }
35 interface Function<T extends (...args: any) => any> {
36 /**
37 * @see _.ary
38 */
39 ary(n?: number): Function<(...args: any[]) => any>;
40 }
41 interface FunctionChain<T extends (...args: any) => any> {
42 /**
43 * @see _.ary
44 */
45 ary(n?: number): FunctionChain<(...args: any[]) => any>;
46 }
47 interface LoDashStatic {
48 /**
49 * Creates a function that invokes func, with the this binding and arguments of the created function, while
50 * it’s called less than n times. Subsequent calls to the created function return the result of the last func
51 * invocation.
52 *
53 * @param n The number of calls at which func is no longer invoked.
54 * @param func The function to restrict.
55 * @return Returns the new restricted function.
56 */
57 before<TFunc extends (...args: any[]) => any>(n: number, func: TFunc): TFunc;
58 }
59 interface Primitive<T> {
60 /**
61 * @see _.before
62 */
63 before<TFunc extends (...args: any[]) => any>(func: TFunc): Function<TFunc>;
64 }
65 interface PrimitiveChain<T> {
66 /**
67 * @see _.before
68 */
69 before<TFunc extends (...args: any[]) => any>(func: TFunc): FunctionChain<TFunc>;
70 }
71 interface FunctionBind {
72 /**
73 * @see _.placeholder
74 */
75 placeholder: __;
76 (func: (...args: any[]) => any, thisArg: any, ...partials: any[]): (...args: any[]) => any;
77 }
78 interface LoDashStatic {
79 /**
80 * Creates a function that invokes func with the this binding of thisArg and prepends any additional _.bind
81 * arguments to those provided to the bound function.
82 *
83 * The _.bind.placeholder value, which defaults to _ in monolithic builds, may be used as a placeholder for
84 * partially applied arguments.
85 *
86 * Note: Unlike native Function#bind this method does not set the "length" property of bound functions.
87 *
88 * @param func The function to bind.
89 * @param thisArg The this binding of func.
90 * @param partials The arguments to be partially applied.
91 * @return Returns the new bound function.
92 */
93 bind: FunctionBind;
94 }
95 interface LoDashImplicitWrapper<TValue> {
96 /**
97 * @see _.bind
98 */
99 bind(thisArg: any, ...partials: any[]): Function<(...args: any[]) => any>;
100 }
101 interface LoDashExplicitWrapper<TValue> {
102 /**
103 * @see _.bind
104 */
105 bind(thisArg: any, ...partials: any[]): FunctionChain<(...args: any[]) => any>;
106 }
107 interface FunctionBindKey {
108 placeholder: __;
109 (object: object, key: string, ...partials: any[]): (...args: any[]) => any;
110 }
111 interface LoDashStatic {
112 /**
113 * Creates a function that invokes the method at object[key] and prepends any additional _.bindKey arguments
114 * to those provided to the bound function.
115 *
116 * This method differs from _.bind by allowing bound functions to reference methods that may be redefined
117 * or don’t yet exist. See Peter Michaux’s article for more details.
118 *
119 * The _.bindKey.placeholder value, which defaults to _ in monolithic builds, may be used as a placeholder
120 * for partially applied arguments.
121 *
122 * @param object The object the method belongs to.
123 * @param key The key of the method.
124 * @param partials The arguments to be partially applied.
125 * @return Returns the new bound function.
126 */
127 bindKey: FunctionBindKey;
128 }
129 interface LoDashImplicitWrapper<TValue> {
130 /**
131 * @see _.bindKey
132 */
133 bindKey(key: string, ...partials: any[]): Function<(...args: any[]) => any>;
134 }
135 interface LoDashExplicitWrapper<TValue> {
136 /**
137 * @see _.bindKey
138 */
139 bindKey(key: string, ...partials: any[]): FunctionChain<(...args: any[]) => any>;
140 }
141 interface Curry {
142 <T1, R>(func: (t1: T1) => R, arity?: number): CurriedFunction1<T1, R>;
143 <T1, T2, R>(func: (t1: T1, t2: T2) => R, arity?: number): CurriedFunction2<T1, T2, R>;
144 <T1, T2, T3, R>(func: (t1: T1, t2: T2, t3: T3) => R, arity?: number): CurriedFunction3<T1, T2, T3, R>;
145 <T1, T2, T3, T4, R>(func: (t1: T1, t2: T2, t3: T3, t4: T4) => R, arity?: number): CurriedFunction4<T1, T2, T3, T4, R>;
146 <T1, T2, T3, T4, T5, R>(func: (t1: T1, t2: T2, t3: T3, t4: T4, t5: T5) => R, arity?: number): CurriedFunction5<T1, T2, T3, T4, T5, R>;
147 (func: (...args: any[]) => any, arity?: number): (...args: any[]) => any;
148 placeholder: __;
149 }
150 interface LoDashStatic {
151 curry: Curry;
152 }
153 interface CurriedFunction1<T1, R> {
154 (): CurriedFunction1<T1, R>;
155 (t1: T1): R;
156 }
157 interface CurriedFunction2<T1, T2, R> {
158 (): CurriedFunction2<T1, T2, R>;
159 (t1: T1): CurriedFunction1<T2, R>;
160 (t1: __, t2: T2): CurriedFunction1<T1, R>;
161 (t1: T1, t2: T2): R;
162 }
163 interface CurriedFunction3<T1, T2, T3, R> {
164 (): CurriedFunction3<T1, T2, T3, R>;
165 (t1: T1): CurriedFunction2<T2, T3, R>;
166 (t1: __, t2: T2): CurriedFunction2<T1, T3, R>;
167 (t1: T1, t2: T2): CurriedFunction1<T3, R>;
168 (t1: __, t2: __, t3: T3): CurriedFunction2<T1, T2, R>;
169 (t1: T1, t2: __, t3: T3): CurriedFunction1<T2, R>;
170 (t1: __, t2: T2, t3: T3): CurriedFunction1<T1, R>;
171 (t1: T1, t2: T2, t3: T3): R;
172 }
173 interface CurriedFunction4<T1, T2, T3, T4, R> {
174 (): CurriedFunction4<T1, T2, T3, T4, R>;
175 (t1: T1): CurriedFunction3<T2, T3, T4, R>;
176 (t1: __, t2: T2): CurriedFunction3<T1, T3, T4, R>;
177 (t1: T1, t2: T2): CurriedFunction2<T3, T4, R>;
178 (t1: __, t2: __, t3: T3): CurriedFunction3<T1, T2, T4, R>;
179 (t1: __, t2: __, t3: T3): CurriedFunction2<T2, T4, R>;
180 (t1: __, t2: T2, t3: T3): CurriedFunction2<T1, T4, R>;
181 (t1: T1, t2: T2, t3: T3): CurriedFunction1<T4, R>;
182 (t1: __, t2: __, t3: __, t4: T4): CurriedFunction3<T1, T2, T3, R>;
183 (t1: T1, t2: __, t3: __, t4: T4): CurriedFunction2<T2, T3, R>;
184 (t1: __, t2: T2, t3: __, t4: T4): CurriedFunction2<T1, T3, R>;
185 (t1: __, t2: __, t3: T3, t4: T4): CurriedFunction2<T1, T2, R>;
186 (t1: T1, t2: T2, t3: __, t4: T4): CurriedFunction1<T3, R>;
187 (t1: T1, t2: __, t3: T3, t4: T4): CurriedFunction1<T2, R>;
188 (t1: __, t2: T2, t3: T3, t4: T4): CurriedFunction1<T1, R>;
189 (t1: T1, t2: T2, t3: T3, t4: T4): R;
190 }
191 interface CurriedFunction5<T1, T2, T3, T4, T5, R> {
192 (): CurriedFunction5<T1, T2, T3, T4, T5, R>;
193 (t1: T1): CurriedFunction4<T2, T3, T4, T5, R>;
194 (t1: __, t2: T2): CurriedFunction4<T1, T3, T4, T5, R>;
195 (t1: T1, t2: T2): CurriedFunction3<T3, T4, T5, R>;
196 (t1: __, t2: __, t3: T3): CurriedFunction4<T1, T2, T4, T5, R>;
197 (t1: T1, t2: __, t3: T3): CurriedFunction3<T2, T4, T5, R>;
198 (t1: __, t2: T2, t3: T3): CurriedFunction3<T1, T4, T5, R>;
199 (t1: T1, t2: T2, t3: T3): CurriedFunction2<T4, T5, R>;
200 (t1: __, t2: __, t3: __, t4: T4): CurriedFunction4<T1, T2, T3, T5, R>;
201 (t1: T1, t2: __, t3: __, t4: T4): CurriedFunction3<T2, T3, T5, R>;
202 (t1: __, t2: T2, t3: __, t4: T4): CurriedFunction3<T1, T3, T5, R>;
203 (t1: __, t2: __, t3: T3, t4: T4): CurriedFunction3<T1, T2, T5, R>;
204 (t1: T1, t2: T2, t3: __, t4: T4): CurriedFunction2<T3, T5, R>;
205 (t1: T1, t2: __, t3: T3, t4: T4): CurriedFunction2<T2, T5, R>;
206 (t1: __, t2: T2, t3: T3, t4: T4): CurriedFunction2<T1, T5, R>;
207 (t1: T1, t2: T2, t3: T3, t4: T4): CurriedFunction1<T5, R>;
208 (t1: __, t2: __, t3: __, t4: __, t5: T5): CurriedFunction4<T1, T2, T3, T4, R>;
209 (t1: T1, t2: __, t3: __, t4: __, t5: T5): CurriedFunction3<T2, T3, T4, R>;
210 (t1: __, t2: T2, t3: __, t4: __, t5: T5): CurriedFunction3<T1, T3, T4, R>;
211 (t1: __, t2: __, t3: T3, t4: __, t5: T5): CurriedFunction3<T1, T2, T4, R>;
212 (t1: __, t2: __, t3: __, t4: T4, t5: T5): CurriedFunction3<T1, T2, T3, R>;
213 (t1: T1, t2: T2, t3: __, t4: __, t5: T5): CurriedFunction2<T3, T4, R>;
214 (t1: T1, t2: __, t3: T3, t4: __, t5: T5): CurriedFunction2<T2, T4, R>;
215 (t1: T1, t2: __, t3: __, t4: T4, t5: T5): CurriedFunction2<T2, T3, R>;
216 (t1: __, t2: T2, t3: T3, t4: __, t5: T5): CurriedFunction2<T1, T4, R>;
217 (t1: __, t2: T2, t3: __, t4: T4, t5: T5): CurriedFunction2<T1, T3, R>;
218 (t1: __, t2: __, t3: T3, t4: T4, t5: T5): CurriedFunction2<T1, T2, R>;
219 (t1: T1, t2: T2, t3: T3, t4: __, t5: T5): CurriedFunction1<T4, R>;
220 (t1: T1, t2: T2, t3: __, t4: T4, t5: T5): CurriedFunction1<T3, R>;
221 (t1: T1, t2: __, t3: T3, t4: T4, t5: T5): CurriedFunction1<T2, R>;
222 (t1: __, t2: T2, t3: T3, t4: T4, t5: T5): CurriedFunction1<T1, R>;
223 (t1: T1, t2: T2, t3: T3, t4: T4, t5: T5): R;
224 }
225 interface RightCurriedFunction1<T1, R> {
226 (): RightCurriedFunction1<T1, R>;
227 (t1: T1): R;
228 }
229 interface RightCurriedFunction2<T1, T2, R> {
230 (): RightCurriedFunction2<T1, T2, R>;
231 (t2: T2): RightCurriedFunction1<T1, R>;
232 (t1: T1, t2: __): RightCurriedFunction1<T2, R>;
233 (t1: T1, t2: T2): R;
234 }
235 interface RightCurriedFunction3<T1, T2, T3, R> {
236 (): RightCurriedFunction3<T1, T2, T3, R>;
237 (t3: T3): RightCurriedFunction2<T1, T2, R>;
238 (t2: T2, t3: __): RightCurriedFunction2<T1, T3, R>;
239 (t2: T2, t3: T3): RightCurriedFunction1<T1, R>;
240 (t1: T1, t2: __, t3: __): RightCurriedFunction2<T2, T3, R>;
241 (t1: T1, t2: T2, t3: __): RightCurriedFunction1<T3, R>;
242 (t1: T1, t2: __, t3: T3): RightCurriedFunction1<T2, R>;
243 (t1: T1, t2: T2, t3: T3): R;
244 }
245 interface RightCurriedFunction4<T1, T2, T3, T4, R> {
246 (): RightCurriedFunction4<T1, T2, T3, T4, R>;
247 (t4: T4): RightCurriedFunction3<T1, T2, T3, R>;
248 (t3: T3, t4: __): RightCurriedFunction3<T1, T2, T4, R>;
249 (t3: T3, t4: T4): RightCurriedFunction2<T1, T2, R>;
250 (t2: T2, t3: __, t4: __): RightCurriedFunction3<T1, T3, T4, R>;
251 (t2: T2, t3: T3, t4: __): RightCurriedFunction2<T1, T4, R>;
252 (t2: T2, t3: __, t4: T4): RightCurriedFunction2<T1, T3, R>;
253 (t2: T2, t3: T3, t4: T4): RightCurriedFunction1<T1, R>;
254 (t1: T1, t2: __, t3: __, t4: __): RightCurriedFunction3<T2, T3, T4, R>;
255 (t1: T1, t2: T2, t3: __, t4: __): RightCurriedFunction2<T3, T4, R>;
256 (t1: T1, t2: __, t3: T3, t4: __): RightCurriedFunction2<T2, T4, R>;
257 (t1: T1, t2: __, t3: __, t4: T4): RightCurriedFunction2<T2, T3, R>;
258 (t1: T1, t2: T2, t3: T3, t4: __): RightCurriedFunction1<T4, R>;
259 (t1: T1, t2: T2, t3: __, t4: T4): RightCurriedFunction1<T3, R>;
260 (t1: T1, t2: __, t3: T3, t4: T4): RightCurriedFunction1<T2, R>;
261 (t1: T1, t2: T2, t3: T3, t4: T4): R;
262 }
263 interface RightCurriedFunction5<T1, T2, T3, T4, T5, R> {
264 (): RightCurriedFunction5<T1, T2, T3, T4, T5, R>;
265 (t5: T5): RightCurriedFunction4<T1, T2, T3, T4, R>;
266 (t4: T4, t5: __): RightCurriedFunction4<T1, T2, T3, T5, R>;
267 (t4: T4, t5: T5): RightCurriedFunction3<T1, T2, T3, R>;
268 (t3: T3, t4: __, t5: __): RightCurriedFunction4<T1, T2, T4, T5, R>;
269 (t3: T3, t4: T4, t5: __): RightCurriedFunction3<T1, T2, T5, R>;
270 (t3: T3, t4: __, t5: T5): RightCurriedFunction3<T1, T2, T4, R>;
271 (t3: T3, t4: T4, t5: T5): RightCurriedFunction2<T1, T2, R>;
272 (t2: T2, t3: __, t4: __, t5: __): RightCurriedFunction4<T1, T3, T4, T5, R>;
273 (t2: T2, t3: T3, t4: __, t5: __): RightCurriedFunction3<T1, T4, T5, R>;
274 (t2: T2, t3: __, t4: T4, t5: __): RightCurriedFunction3<T1, T3, T5, R>;
275 (t2: T2, t3: __, t4: __, t5: T5): RightCurriedFunction3<T1, T3, T4, R>;
276 (t2: T2, t3: T3, t4: T4, t5: __): RightCurriedFunction2<T1, T5, R>;
277 (t2: T2, t3: T3, t4: __, t5: T5): RightCurriedFunction2<T1, T4, R>;
278 (t2: T2, t3: __, t4: T4, t5: T5): RightCurriedFunction2<T1, T3, R>;
279 (t2: T2, t3: T3, t4: T4, t5: T5): RightCurriedFunction1<T1, R>;
280 (t1: T1, t2: __, t3: __, t4: __, t5: __): RightCurriedFunction4<T2, T3, T4, T5, R>;
281 (t1: T1, t2: T2, t3: __, t4: __, t5: __): RightCurriedFunction3<T3, T4, T5, R>;
282 (t1: T1, t2: __, t3: T3, t4: __, t5: __): RightCurriedFunction3<T2, T4, T5, R>;
283 (t1: T1, t2: __, t3: __, t4: T4, t5: __): RightCurriedFunction3<T2, T3, T5, R>;
284 (t1: T1, t2: __, t3: __, t4: __, t5: T5): RightCurriedFunction3<T2, T3, T4, R>;
285 (t1: T1, t2: T2, t3: T3, t4: __, t5: __): RightCurriedFunction2<T4, T5, R>;
286 (t1: T1, t2: T2, t3: __, t4: T4, t5: __): RightCurriedFunction2<T3, T5, R>;
287 (t1: T1, t2: T2, t3: __, t4: __, t5: T5): RightCurriedFunction2<T3, T4, R>;
288 (t1: T1, t2: __, t3: T3, t4: T4, t5: __): RightCurriedFunction2<T2, T5, R>;
289 (t1: T1, t2: __, t3: T3, t4: __, t5: T5): RightCurriedFunction2<T2, T4, R>;
290 (t1: T1, t2: __, t3: __, t4: T4, t5: T5): RightCurriedFunction2<T2, T3, R>;
291 (t1: T1, t2: T2, t3: T3, t4: T4, t5: __): RightCurriedFunction1<T5, R>;
292 (t1: T1, t2: T2, t3: T3, t4: __, t5: T5): RightCurriedFunction1<T4, R>;
293 (t1: T1, t2: T2, t3: __, t4: T4, t5: T5): RightCurriedFunction1<T3, R>;
294 (t1: T1, t2: __, t3: T3, t4: T4, t5: T5): RightCurriedFunction1<T2, R>;
295 (t1: T1, t2: T2, t3: T3, t4: T4, t5: T5): R;
296 }
297 interface Function<T extends (...args: any) => any> {
298 /**
299 * @see _.curry
300 */
301 curry(arity?: number):
302 T extends (arg1: infer T1) => infer R ? Function<CurriedFunction1<T1, R>> :
303 T extends (arg1: infer T1, arg2: infer T2) => infer R ? Function<CurriedFunction2<T1, T2, R>> :
304 T extends (arg1: infer T1, arg2: infer T2, arg3: infer T3) => infer R ? Function<CurriedFunction3<T1, T2, T3, R>> :
305 T extends (arg1: infer T1, arg2: infer T2, arg3: infer T3, arg4: infer T4) => infer R ? Function<CurriedFunction4<T1, T2, T3, T4, R>> :
306 T extends (arg1: infer T1, arg2: infer T2, arg3: infer T3, arg4: infer T4, arg5: infer T5) => infer R ? Function<CurriedFunction5<T1, T2, T3, T4, T5, R>> :
307 Function<(...args: any[]) => any>;
308 }
309 interface FunctionChain<T extends (...args: any) => any> {
310 /**
311 * @see _.curry
312 */
313 curry(arity?: number):
314 T extends (arg1: infer T1) => infer R ? FunctionChain<CurriedFunction1<T1, R>> :
315 T extends (arg1: infer T1, arg2: infer T2) => infer R ? FunctionChain<CurriedFunction2<T1, T2, R>> :
316 T extends (arg1: infer T1, arg2: infer T2, arg3: infer T3) => infer R ? FunctionChain<CurriedFunction3<T1, T2, T3, R>> :
317 T extends (arg1: infer T1, arg2: infer T2, arg3: infer T3, arg4: infer T4) => infer R ? FunctionChain<CurriedFunction4<T1, T2, T3, T4, R>> :
318 T extends (arg1: infer T1, arg2: infer T2, arg3: infer T3, arg4: infer T4, arg5: infer T5) => infer R ? FunctionChain<CurriedFunction5<T1, T2, T3, T4, T5, R>> :
319 FunctionChain<(...args: any[]) => any>;
320 }
321 interface CurryRight {
322 <T1, R>(func: (t1: T1) => R, arity?: number): RightCurriedFunction1<T1, R>;
323 <T1, T2, R>(func: (t1: T1, t2: T2) => R, arity?: number): RightCurriedFunction2<T1, T2, R>;
324 <T1, T2, T3, R>(func: (t1: T1, t2: T2, t3: T3) => R, arity?: number): RightCurriedFunction3<T1, T2, T3, R>;
325 <T1, T2, T3, T4, R>(func: (t1: T1, t2: T2, t3: T3, t4: T4) => R, arity?: number): RightCurriedFunction4<T1, T2, T3, T4, R>;
326 <T1, T2, T3, T4, T5, R>(func: (t1: T1, t2: T2, t3: T3, t4: T4, t5: T5) => R, arity?: number): RightCurriedFunction5<T1, T2, T3, T4, T5, R>;
327 (func: (...args: any[]) => any, arity?: number): (...args: any[]) => any;
328 placeholder: __;
329 }
330 interface LoDashStatic {
331 curryRight: CurryRight;
332 }
333 interface Function<T extends (...args: any) => any> {
334 /**
335 * @see _.curryRight
336 */
337 curryRight(arity?: number):
338 T extends (arg1: infer T1) => infer R ? Function<RightCurriedFunction1<T1, R>> :
339 T extends (arg1: infer T1, arg2: infer T2) => infer R ? Function<RightCurriedFunction2<T1, T2, R>> :
340 T extends (arg1: infer T1, arg2: infer T2, arg3: infer T3) => infer R ? Function<RightCurriedFunction3<T1, T2, T3, R>> :
341 T extends (arg1: infer T1, arg2: infer T2, arg3: infer T3, arg4: infer T4) => infer R ? Function<RightCurriedFunction4<T1, T2, T3, T4, R>> :
342 T extends (arg1: infer T1, arg2: infer T2, arg3: infer T3, arg4: infer T4, arg5: infer T5) => infer R ? Function<RightCurriedFunction5<T1, T2, T3, T4, T5, R>> :
343 Function<(...args: any[]) => any>;
344 }
345 interface FunctionChain<T extends (...args: any) => any> {
346 /**
347 * @see _.curryRight
348 */
349 curryRight(arity?: number):
350 T extends (arg1: infer T1) => infer R ? FunctionChain<RightCurriedFunction1<T1, R>> :
351 T extends (arg1: infer T1, arg2: infer T2) => infer R ? FunctionChain<RightCurriedFunction2<T1, T2, R>> :
352 T extends (arg1: infer T1, arg2: infer T2, arg3: infer T3) => infer R ? FunctionChain<RightCurriedFunction3<T1, T2, T3, R>> :
353 T extends (arg1: infer T1, arg2: infer T2, arg3: infer T3, arg4: infer T4) => infer R ? FunctionChain<RightCurriedFunction4<T1, T2, T3, T4, R>> :
354 T extends (arg1: infer T1, arg2: infer T2, arg3: infer T3, arg4: infer T4, arg5: infer T5) => infer R ? FunctionChain<RightCurriedFunction5<T1, T2, T3, T4, T5, R>> :
355 FunctionChain<(...args: any[]) => any>;
356 }
357 interface DebounceSettings {
358 /**
359 * @see _.leading
360 */
361 leading?: boolean | undefined;
362 /**
363 * @see _.maxWait
364 */
365 maxWait?: number | undefined;
366 /**
367 * @see _.trailing
368 */
369 trailing?: boolean | undefined;
370 }
371 interface DebounceSettingsLeading extends DebounceSettings {
372 leading: true;
373 }
374 interface DebouncedFunc<T extends (...args: any[]) => any> {
375 /**
376 * Call the original function, but applying the debounce rules.
377 *
378 * If the debounced function can be run immediately, this calls it and returns its return
379 * value.
380 *
381 * Otherwise, it returns the return value of the last invocation, or undefined if the debounced
382 * function was not invoked yet.
383 */
384 (...args: Parameters<T>): ReturnType<T> | undefined;
385
386 /**
387 * Throw away any pending invocation of the debounced function.
388 */
389 cancel(): void;
390
391 /**
392 * If there is a pending invocation of the debounced function, invoke it immediately and return
393 * its return value.
394 *
395 * Otherwise, return the value from the last invocation, or undefined if the debounced function
396 * was never invoked.
397 */
398 flush(): ReturnType<T> | undefined;
399 }
400 interface DebouncedFuncLeading<T extends (...args: any[]) => any> extends DebouncedFunc<T> {
401 (...args: Parameters<T>): ReturnType<T>;
402 flush(): ReturnType<T>;
403 }
404 interface LoDashStatic {
405 /**
406 * Creates a debounced function that delays invoking func until after wait milliseconds have elapsed since
407 * the last time the debounced function was invoked. The debounced function comes with a cancel method to
408 * cancel delayed invocations and a flush method to immediately invoke them. Provide an options object to
409 * indicate that func should be invoked on the leading and/or trailing edge of the wait timeout. Subsequent
410 * calls to the debounced function return the result of the last func invocation.
411 *
412 * Note: If leading and trailing options are true, func is invoked on the trailing edge of the timeout only
413 * if the the debounced function is invoked more than once during the wait timeout.
414 *
415 * See David Corbacho’s article for details over the differences between _.debounce and _.throttle.
416 *
417 * @param func The function to debounce.
418 * @param wait The number of milliseconds to delay.
419 * @param options The options object.
420 * @param options.leading Specify invoking on the leading edge of the timeout.
421 * @param options.maxWait The maximum time func is allowed to be delayed before it’s invoked.
422 * @param options.trailing Specify invoking on the trailing edge of the timeout.
423 * @return Returns the new debounced function.
424 */
425 debounce<T extends (...args: any) => any>(func: T, wait: number | undefined, options: DebounceSettingsLeading): DebouncedFuncLeading<T>;
426 debounce<T extends (...args: any) => any>(func: T, wait?: number, options?: DebounceSettings): DebouncedFunc<T>;
427 }
428 interface Function<T extends (...args: any) => any> {
429 /**
430 * @see _.debounce
431 */
432 debounce(
433 wait: number | undefined,
434 options: DebounceSettingsLeading
435 ): T extends (...args: any[]) => any ? Function<DebouncedFuncLeading<T>> : never;
436 debounce(
437 wait?: number,
438 options?: DebounceSettings
439 ): T extends (...args: any[]) => any ? Function<DebouncedFunc<T>> : never;
440 }
441 interface FunctionChain<T extends (...args: any) => any> {
442 /**
443 * @see _.debounce
444 */
445 debounce(
446 wait: number | undefined,
447 options: DebounceSettingsLeading
448 ): T extends (...args: any[]) => any ? FunctionChain<DebouncedFuncLeading<T>> : never;
449 debounce(
450 wait?: number,
451 options?: DebounceSettings
452 ): T extends (...args: any[]) => any ? FunctionChain<DebouncedFunc<T>> : never;
453 }
454 interface LoDashStatic {
455 /**
456 * Defers invoking the func until the current call stack has cleared. Any additional arguments are provided to
457 * func when it’s invoked.
458 *
459 * @param func The function to defer.
460 * @param args The arguments to invoke the function with.
461 * @return Returns the timer id.
462 */
463 defer(func: (...args: any[]) => any, ...args: any[]): number;
464 }
465 interface LoDashImplicitWrapper<TValue> {
466 /**
467 * @see _.defer
468 */
469 defer(...args: any[]): Primitive<number>;
470 }
471 interface LoDashExplicitWrapper<TValue> {
472 /**
473 * @see _.defer
474 */
475 defer(...args: any[]): PrimitiveChain<number>;
476 }
477 interface LoDashStatic {
478 /**
479 * Invokes func after wait milliseconds. Any additional arguments are provided to func when it’s invoked.
480 *
481 * @param func The function to delay.
482 * @param wait The number of milliseconds to delay invocation.
483 * @param args The arguments to invoke the function with.
484 * @return Returns the timer id.
485 */
486 delay(func: (...args: any[]) => any, wait: number, ...args: any[]): number;
487 }
488 interface LoDashImplicitWrapper<TValue> {
489 /**
490 * @see _.delay
491 */
492 delay(wait: number, ...args: any[]): Primitive<number>;
493 }
494 interface LoDashExplicitWrapper<TValue> {
495 /**
496 * @see _.delay
497 */
498 delay(wait: number, ...args: any[]): PrimitiveChain<number>;
499 }
500 interface LoDashStatic {
501 /**
502 * Creates a function that invokes `func` with arguments reversed.
503 *
504 * @category Function
505 * @param func The function to flip arguments for.
506 * @returns Returns the new function.
507 * @example
508 *
509 * var flipped = _.flip(function() {
510 * return _.toArray(arguments);
511 * });
512 *
513 * flipped('a', 'b', 'c', 'd');
514 * // => ['d', 'c', 'b', 'a']
515 */
516 flip<T extends (...args: any) => any>(func: T): T;
517 }
518 interface Function<T extends (...args: any) => any> {
519 /**
520 * @see _.flip
521 */
522 flip(): this;
523 }
524 interface FunctionChain<T extends (...args: any) => any> {
525 /**
526 * @see _.flip
527 */
528 flip(): this;
529 }
530 interface MemoizedFunction {
531 /**
532 * @see _.cache
533 */
534 cache: MapCache;
535 }
536 interface LoDashStatic {
537 /**
538 * Creates a function that memoizes the result of func. If resolver is provided it determines the cache key for
539 * storing the result based on the arguments provided to the memoized function. By default, the first argument
540 * provided to the memoized function is coerced to a string and used as the cache key. The func is invoked with
541 * the this binding of the memoized function.
542 *
543 * @param func The function to have its output memoized.
544 * @param resolver The function to resolve the cache key.
545 * @return Returns the new memoizing function.
546 */
547 memoize: {
548 <T extends (...args: any) => any>(func: T, resolver?: (...args: Parameters<T>) => any): T & MemoizedFunction;
549 Cache: MapCacheConstructor;
550 };
551 }
552 interface Function<T extends (...args: any) => any> {
553 /**
554 * @see _.memoize
555 */
556 memoize(resolver?: (...args: any[]) => any): Function<T & MemoizedFunction>;
557 }
558 interface FunctionChain<T extends (...args: any) => any> {
559 /**
560 * @see _.memoize
561 */
562 memoize(resolver?: (...args: any[]) => any): FunctionChain<T & MemoizedFunction>;
563 }
564 interface LoDashStatic {
565 /**
566 * Creates a function that negates the result of the predicate func. The func predicate is invoked with
567 * the this binding and arguments of the created function.
568 *
569 * @param predicate The predicate to negate.
570 * @return Returns the new function.
571 */
572 negate<T extends any[]>(predicate: (...args: T) => boolean): (...args: T) => boolean;
573 }
574 interface Function<T extends (...args: any) => any> {
575 /**
576 * @see _.negate
577 */
578 negate(): Function<(...args: Parameters<T>) => boolean>;
579 }
580 interface FunctionChain<T extends (...args: any) => any> {
581 /**
582 * @see _.negate
583 */
584 negate(): FunctionChain<(...args: Parameters<T>) => boolean>;
585 }
586 interface LoDashStatic {
587 /**
588 * Creates a function that is restricted to invoking func once. Repeat calls to the function return the value
589 * of the first call. The func is invoked with the this binding and arguments of the created function.
590 *
591 * @param func The function to restrict.
592 * @return Returns the new restricted function.
593 */
594 once<T extends (...args: any) => any>(func: T): T;
595 }
596 interface Function<T extends (...args: any) => any> {
597 /**
598 * @see _.once
599 */
600 once(): Function<T>;
601 }
602 interface FunctionChain<T extends (...args: any) => any> {
603 /**
604 * @see _.once
605 */
606 once(): FunctionChain<T>;
607 }
608 interface LoDashStatic {
609 /**
610 * Creates a function that runs each argument through a corresponding transform function.
611 *
612 * @param func The function to wrap.
613 * @param transforms The functions to transform arguments, specified as individual functions or arrays
614 * of functions.
615 * @return Returns the new function.
616 */
617 overArgs(func: (...args: any[]) => any, ...transforms: Array<Many<(...args: any[]) => any>>): (...args: any[]) => any;
618 }
619 interface Function<T extends (...args: any) => any> {
620 /**
621 * @see _.overArgs
622 */
623 overArgs(...transforms: Array<Many<(...args: any[]) => any>>): Function<(...args: any[]) => any>;
624 }
625 interface FunctionChain<T extends (...args: any) => any> {
626 /**
627 * @see _.overArgs
628 */
629 overArgs(...transforms: Array<Many<(...args: any[]) => any>>): FunctionChain<(...args: any[]) => any>;
630 }
631 interface LoDashStatic {
632 /**
633 * Creates a function that, when called, invokes func with any additional partial arguments
634 * prepended to those provided to the new function. This method is similar to _.bind except
635 * it does not alter the this binding.
636 * @param func The function to partially apply arguments to.
637 * @param args Arguments to be partially applied.
638 * @return The new partially applied function.
639 */
640 partial: Partial;
641 }
642 type __ = LoDashStatic;
643 type Function0<R> = () => R;
644 type Function1<T1, R> = (t1: T1) => R;
645 type Function2<T1, T2, R> = (t1: T1, t2: T2) => R;
646 type Function3<T1, T2, T3, R> = (t1: T1, t2: T2, t3: T3) => R;
647 type Function4<T1, T2, T3, T4, R> = (t1: T1, t2: T2, t3: T3, t4: T4) => R;
648 interface Partial {
649 <T1, T2, R>(func: Function2<T1, T2, R>, plc1: __, arg2: T2): Function1<T1, R>;
650 <T1, T2, T3, R>(func: Function3<T1, T2, T3, R>, plc1: __, arg2: T2): Function2<T1, T3, R>;
651 <T1, T2, T3, R>(func: Function3<T1, T2, T3, R>, plc1: __, plc2: __, arg3: T3): Function2<T1, T2, R>;
652 <T1, T2, T3, R>(func: Function3<T1, T2, T3, R>, arg1: T1, plc2: __, arg3: T3): Function1<T2, R>;
653 <T1, T2, T3, R>(func: Function3<T1, T2, T3, R>, plc1: __, arg2: T2, arg3: T3): Function1<T1, R>;
654 <T1, T2, T3, T4, R>(func: Function4<T1, T2, T3, T4, R>, plc1: __, arg2: T2): Function3<T1, T3, T4, R>;
655 <T1, T2, T3, T4, R>(func: Function4<T1, T2, T3, T4, R>, plc1: __, plc2: __, arg3: T3): Function3<T1, T2, T4, R>;
656 <T1, T2, T3, T4, R>(func: Function4<T1, T2, T3, T4, R>, arg1: T1, plc2: __, arg3: T3): Function2<T2, T4, R>;
657 <T1, T2, T3, T4, R>(func: Function4<T1, T2, T3, T4, R>, plc1: __, arg2: T2, arg3: T3): Function2<T1, T4, R>;
658 <T1, T2, T3, T4, R>(func: Function4<T1, T2, T3, T4, R>, plc1: __, plc2: __, plc3: __, arg4: T4): Function3<T1, T2, T3, R>;
659 <T1, T2, T3, T4, R>(func: Function4<T1, T2, T3, T4, R>, arg1: T1, plc2: __, plc3: __, arg4: T4): Function2<T2, T3, R>;
660 <T1, T2, T3, T4, R>(func: Function4<T1, T2, T3, T4, R>, plc1: __, arg2: T2, plc3: __, arg4: T4): Function2<T1, T3, R>;
661 <T1, T2, T3, T4, R>(func: Function4<T1, T2, T3, T4, R>, arg1: T1, arg2: T2, plc3: __, arg4: T4): Function1<T3, R>;
662 <T1, T2, T3, T4, R>(func: Function4<T1, T2, T3, T4, R>, plc1: __, plc2: __, arg3: T3, arg4: T4): Function2<T1, T2, R>;
663 <T1, T2, T3, T4, R>(func: Function4<T1, T2, T3, T4, R>, arg1: T1, plc2: __, arg3: T3, arg4: T4): Function1<T2, R>;
664 <T1, T2, T3, T4, R>(func: Function4<T1, T2, T3, T4, R>, plc1: __, arg2: T2, arg3: T3, arg4: T4): Function1<T1, R>;
665 <TS extends any[], R>(func: (...ts: TS) => R): (...ts: TS) => R;
666 <TS extends any[], T1, R>(func: (t1: T1, ...ts: TS) => R, arg1: T1): (...ts: TS) => R;
667 <TS extends any[], T1, T2, R>(func: (t1: T1, t2: T2, ...ts: TS) => R, t1: T1, t2: T2): (...ts: TS) => R;
668 <TS extends any[], T1, T2, T3, R>(func: (t1: T1, t2: T2, t3: T3, ...ts: TS) => R, t1: T1, t2: T2, t3: T3): (...ts: TS) => R;
669 <TS extends any[], T1, T2, T3, T4, R>(func: (t1: T1, t2: T2, t3: T3, t4: T4, ...ts: TS) => R, t1: T1, t2: T2, t3: T3, t4: T4): (...ts: TS) => R;
670 placeholder: __;
671 }
672 interface Function<T extends (...args: any) => any> {
673 /**
674 * @see _.partial
675 */
676 partial<T2>(plc1: __, arg2: T2): Function<
677 T extends Function2<infer T1, T2, infer R> ? Function1<T1, R> :
678 T extends Function3<infer T1, T2, infer T3, infer R> ? Function2<T1, T3, R> :
679 T extends Function4<infer T1, T2, infer T3, infer T4, infer R> ? Function3<T1, T3, T4, R> :
680 any
681 >;
682 /**
683 * @see _.partial
684 */
685 partial<T3>(plc1: __, plc2: __, arg3: T3): Function<
686 T extends Function3<infer T1, infer T2, T3, infer R> ? Function2<T1, T2, R> :
687 T extends Function4<infer T1, infer T2, T3, infer T4, infer R> ? Function3<T1, T2, T4, R> :
688 any
689 >;
690 /**
691 * @see _.partial
692 */
693 partial<T1, T3>(arg1: T1, plc2: __, arg3: T3): Function<
694 T extends Function3<T1, infer T2, T3, infer R> ? Function1<T2, R> :
695 T extends Function4<T1, infer T2, T3, infer T4, infer R> ? Function2<T2, T4, R> :
696 any
697 >;
698 /**
699 * @see _.partial
700 */
701 partial<T2, T3>(plc1: __, arg2: T2, arg3: T3): Function<
702 T extends Function3<infer T1, T2, T3, infer R> ? Function1<T1, R> :
703 T extends Function4<infer T1, T2, T3, infer T4, infer R> ? Function2<T1, T4, R> :
704 any
705 >;
706 /**
707 * @see _.partial
708 */
709 partial<T3>(plc1: __, plc2: __, arg3: T3): Function<
710 T extends Function4<infer T1, infer T2, T3, infer T4, infer R> ? Function3<T1, T2, T4, R> :
711 any
712 >;
713 /**
714 * @see _.partial
715 */
716 partial<T1, T4>(arg1: T1, plc2: __, plc3: __, arg4: T4): Function<
717 T extends Function4<T1, infer T2, infer T3, T4, infer R> ? Function2<T2, T3, R> :
718 any
719 >;
720 /**
721 * @see _.partial
722 */
723 partial<T2, T4>(plc1: __, arg2: T2, plc3: __, arg4: T4): Function<
724 T extends Function4<infer T1, T2, infer T3, T4, infer R> ? Function2<T1, T3, R> :
725 any
726 >;
727 /**
728 * @see _.partial
729 */
730 partial<T1, T2, T4>(arg1: T1, arg2: T2, plc3: __, arg4: T4): Function<
731 T extends Function4<T1, T2, infer T3, T4, infer R> ? Function1<T3, R> :
732 any
733 >;
734 /**
735 * @see _.partial
736 */
737 partial<T3, T4>(plc1: __, plc2: __, arg3: T3, arg4: T4): Function<
738 T extends Function4<infer T1, infer T2, T3, T4, infer R> ? Function2<T1, T2, R> :
739 any
740 >;
741 /**
742 * @see _.partial
743 */
744 partial<T1, T3, T4>(arg1: T1, plc2: __, arg3: T3, arg4: T4): Function<
745 T extends Function4<T1, infer T2, T3, T4, infer R> ? Function1<T2, R> :
746 any
747 >;
748 /**
749 * @see _.partial
750 */
751 partial<T2, T3, T4>(plc1: __, arg2: T2, arg3: T3, arg4: T4): Function<
752 T extends Function4<infer T1, T2, T3, T4, infer R> ? Function1<T1, R> :
753 any
754 >;
755 /**
756 * @see _.partial
757 */
758 partial<T1, T2, T3, T4>(arg1: T1, arg2: T2, arg3: T3, arg4: T4): Function<
759 T extends (t1: T1, t2: T2, t3: T3, t4: T4, ...ts: infer TS) => infer R ? (...ts: TS) => R :
760 any
761 >;
762 /**
763 * @see _.partial
764 */
765 partial<T1, T2, T3>(arg1: T1, arg2: T2, arg3: T3): Function<
766 T extends (t1: T1, t2: T2, t3: T3, ...ts: infer TS) => infer R ? (...ts: TS) => R :
767 any
768 >;
769 /**
770 * @see _.partial
771 */
772 partial<T1, T2>(arg1: T1, arg2: T2): Function<
773 T extends (t1: T1, t2: T2, ...ts: infer TS) => infer R ? (...ts: TS) => R :
774 any
775 >;
776 /**
777 * @see _.partial
778 */
779 partial<T1>(arg1: T1): Function<
780 T extends (t1: T1, ...ts: infer TS) => infer R ? (...ts: TS) => R :
781 any
782 >;
783 /**
784 * @see _.partial
785 */
786 partial(): Function<T extends (...ts: any[]) => any ? T : any>;
787 }
788 interface FunctionChain<T extends (...args: any) => any> {
789 /**
790 * @see _.partial
791 */
792 partial<T2>(plc1: __, arg2: T2): FunctionChain<
793 T extends Function2<infer T1, T2, infer R> ? Function1<T1, R> :
794 T extends Function3<infer T1, T2, infer T3, infer R> ? Function2<T1, T3, R> :
795 T extends Function4<infer T1, T2, infer T3, infer T4, infer R> ? Function3<T1, T3, T4, R> :
796 any
797 >;
798 /**
799 * @see _.partial
800 */
801 partial<T3>(plc1: __, plc2: __, arg3: T3): FunctionChain<
802 T extends Function3<infer T1, infer T2, T3, infer R> ? Function2<T1, T2, R> :
803 T extends Function4<infer T1, infer T2, T3, infer T4, infer R> ? Function3<T1, T2, T4, R> :
804 any
805 >;
806 /**
807 * @see _.partial
808 */
809 partial<T1, T3>(arg1: T1, plc2: __, arg3: T3): FunctionChain<
810 T extends Function3<T1, infer T2, T3, infer R> ? Function1<T2, R> :
811 T extends Function4<T1, infer T2, T3, infer T4, infer R> ? Function2<T2, T4, R> :
812 any
813 >;
814 /**
815 * @see _.partial
816 */
817 partial<T2, T3>(plc1: __, arg2: T2, arg3: T3): FunctionChain<
818 T extends Function3<infer T1, T2, T3, infer R> ? Function1<T1, R> :
819 T extends Function4<infer T1, T2, T3, infer T4, infer R> ? Function2<T1, T4, R> :
820 any
821 >;
822 /**
823 * @see _.partial
824 */
825 partial<T3>(plc1: __, plc2: __, arg3: T3): FunctionChain<
826 T extends Function4<infer T1, infer T2, T3, infer T4, infer R> ? Function3<T1, T2, T4, R> :
827 any
828 >;
829 /**
830 * @see _.partial
831 */
832 partial<T1, T4>(arg1: T1, plc2: __, plc3: __, arg4: T4): FunctionChain<
833 T extends Function4<T1, infer T2, infer T3, T4, infer R> ? Function2<T2, T3, R> :
834 any
835 >;
836 /**
837 * @see _.partial
838 */
839 partial<T2, T4>(plc1: __, arg2: T2, plc3: __, arg4: T4): FunctionChain<
840 T extends Function4<infer T1, T2, infer T3, T4, infer R> ? Function2<T1, T3, R> :
841 any
842 >;
843 /**
844 * @see _.partial
845 */
846 partial<T1, T2, T4>(arg1: T1, arg2: T2, plc3: __, arg4: T4): FunctionChain<
847 T extends Function4<T1, T2, infer T3, T4, infer R> ? Function1<T3, R> :
848 any
849 >;
850 /**
851 * @see _.partial
852 */
853 partial<T3, T4>(plc1: __, plc2: __, arg3: T3, arg4: T4): FunctionChain<
854 T extends Function4<infer T1, infer T2, T3, T4, infer R> ? Function2<T1, T2, R> :
855 any
856 >;
857 /**
858 * @see _.partial
859 */
860 partial<T1, T3, T4>(arg1: T1, plc2: __, arg3: T3, arg4: T4): FunctionChain<
861 T extends Function4<T1, infer T2, T3, T4, infer R> ? Function1<T2, R> :
862 any
863 >;
864 /**
865 * @see _.partial
866 */
867 partial<T2, T3, T4>(plc1: __, arg2: T2, arg3: T3, arg4: T4): FunctionChain<
868 T extends Function4<infer T1, T2, T3, T4, infer R> ? Function1<T1, R> :
869 any
870 >;
871 /**
872 * @see _.partial
873 */
874 partial<T1, T2, T3, T4>(arg1: T1, arg2: T2, arg3: T3, arg4: T4): FunctionChain<
875 T extends (t1: T1, t2: T2, t3: T3, t4: T4, ...ts: infer TS) => infer R ? (...ts: TS) => R :
876 any
877 >;
878 /**
879 * @see _.partial
880 */
881 partial<T1, T2, T3>(arg1: T1, arg2: T2, arg3: T3): FunctionChain<
882 T extends (t1: T1, t2: T2, t3: T3, ...ts: infer TS) => infer R ? (...ts: TS) => R :
883 any
884 >;
885 /**
886 * @see _.partial
887 */
888 partial<T1, T2>(arg1: T1, arg2: T2): FunctionChain<
889 T extends (t1: T1, t2: T2, ...ts: infer TS) => infer R ? (...ts: TS) => R :
890 any
891 >;
892 /**
893 * @see _.partial
894 */
895 partial<T1>(arg1: T1): FunctionChain<
896 T extends (t1: T1, ...ts: infer TS) => infer R ? (...ts: TS) => R :
897 any
898 >;
899 /**
900 * @see _.partial
901 */
902 partial(): FunctionChain<T extends (...ts: any[]) => any ? T : any>;
903 }
904 interface LoDashStatic {
905 /**
906 * This method is like _.partial except that partial arguments are appended to those provided
907 * to the new function.
908 * @param func The function to partially apply arguments to.
909 * @param args Arguments to be partially applied.
910 * @return The new partially applied function.
911 */
912 partialRight: PartialRight;
913 }
914 interface PartialRight {
915 <R>(func: Function0<R>): Function0<R>;
916 <T1, R>(func: Function1<T1, R>): Function1<T1, R>;
917 <T1, R>(func: Function1<T1, R>, arg1: T1): Function0<R>;
918 <T1, T2, R>(func: Function2<T1, T2, R>): Function2<T1, T2, R>;
919 <T1, T2, R>(func: Function2<T1, T2, R>, arg1: T1, plc2: __): Function1<T2, R>;
920 <T1, T2, R>(func: Function2<T1, T2, R>, arg2: T2): Function1<T1, R>;
921 <T1, T2, R>(func: Function2<T1, T2, R>, arg1: T1, arg2: T2): Function0<R>;
922 <T1, T2, T3, R>(func: Function3<T1, T2, T3, R>): Function3<T1, T2, T3, R>;
923 <T1, T2, T3, R>(func: Function3<T1, T2, T3, R>, arg1: T1, plc2: __, plc3: __): Function2<T2, T3, R>;
924 <T1, T2, T3, R>(func: Function3<T1, T2, T3, R>, arg2: T2, plc3: __): Function2<T1, T3, R>;
925 <T1, T2, T3, R>(func: Function3<T1, T2, T3, R>, arg1: T1, arg2: T2, plc3: __): Function1<T3, R>;
926 <T1, T2, T3, R>(func: Function3<T1, T2, T3, R>, arg3: T3): Function2<T1, T2, R>;
927 <T1, T2, T3, R>(func: Function3<T1, T2, T3, R>, arg1: T1, plc2: __, arg3: T3): Function1<T2, R>;
928 <T1, T2, T3, R>(func: Function3<T1, T2, T3, R>, arg2: T2, arg3: T3): Function1<T1, R>;
929 <T1, T2, T3, R>(func: Function3<T1, T2, T3, R>, arg1: T1, arg2: T2, arg3: T3): Function0<R>;
930 <T1, T2, T3, T4, R>(func: Function4<T1, T2, T3, T4, R>): Function4<T1, T2, T3, T4, R>;
931 <T1, T2, T3, T4, R>(func: Function4<T1, T2, T3, T4, R>, arg1: T1, plc2: __, plc3: __, plc4: __): Function3<T2, T3, T4, R>;
932 <T1, T2, T3, T4, R>(func: Function4<T1, T2, T3, T4, R>, arg2: T2, plc3: __, plc4: __): Function3<T1, T3, T4, R>;
933 <T1, T2, T3, T4, R>(func: Function4<T1, T2, T3, T4, R>, arg1: T1, arg2: T2, plc3: __, plc4: __): Function2<T3, T4, R>;
934 <T1, T2, T3, T4, R>(func: Function4<T1, T2, T3, T4, R>, arg3: T3, plc4: __): Function3<T1, T2, T4, R>;
935 <T1, T2, T3, T4, R>(func: Function4<T1, T2, T3, T4, R>, arg1: T1, plc2: __, arg3: T3, plc4: __): Function2<T2, T4, R>;
936 <T1, T2, T3, T4, R>(func: Function4<T1, T2, T3, T4, R>, arg2: T2, arg3: T3, plc4: __): Function2<T1, T4, R>;
937 <T1, T2, T3, T4, R>(func: Function4<T1, T2, T3, T4, R>, arg1: T1, arg2: T2, arg3: T3, plc4: __): Function1<T4, R>;
938 <T1, T2, T3, T4, R>(func: Function4<T1, T2, T3, T4, R>, arg4: T4): Function3<T1, T2, T3, R>;
939 <T1, T2, T3, T4, R>(func: Function4<T1, T2, T3, T4, R>, arg1: T1, plc2: __, plc3: __, arg4: T4): Function2<T2, T3, R>;
940 <T1, T2, T3, T4, R>(func: Function4<T1, T2, T3, T4, R>, arg2: T2, plc3: __, arg4: T4): Function2<T1, T3, R>;
941 <T1, T2, T3, T4, R>(func: Function4<T1, T2, T3, T4, R>, arg1: T1, arg2: T2, plc3: __, arg4: T4): Function1<T3, R>;
942 <T1, T2, T3, T4, R>(func: Function4<T1, T2, T3, T4, R>, arg3: T3, arg4: T4): Function2<T1, T2, R>;
943 <T1, T2, T3, T4, R>(func: Function4<T1, T2, T3, T4, R>, arg1: T1, plc2: __, arg3: T3, arg4: T4): Function1<T2, R>;
944 <T1, T2, T3, T4, R>(func: Function4<T1, T2, T3, T4, R>, arg2: T2, arg3: T3, arg4: T4): Function1<T1, R>;
945 <T1, T2, T3, T4, R>(func: Function4<T1, T2, T3, T4, R>, arg1: T1, arg2: T2, arg3: T3, arg4: T4): Function0<R>;
946 (func: (...args: any[]) => any, ...args: any[]): (...args: any[]) => any;
947 placeholder: __;
948 }
949 interface Function<T extends (...args: any) => any> {
950 /**
951 * @see _.partialRight
952 */
953 partialRight<T1>(arg1: T1, plc2: __): Function<
954 T extends Function2<T1, infer T2, infer R> ? Function1<T2, R> :
955 any
956 >;
957 /**
958 * @see _.partialRight
959 */
960 partialRight<T2>(arg2: T2): Function<
961 T extends Function2<infer T1, T2, infer R> ? Function1<T1, R> : any
962 >;
963 /**
964 * @see _.partialRight
965 */
966 partialRight<T1>(arg1: T1, plc2: __, plc3: __): Function<
967 T extends Function3<T1, infer T2, infer T3, infer R> ? Function2<T2, T3, R> :
968 any
969 >;
970 /**
971 * @see _.partialRight
972 */
973 partialRight<T2>(arg2: T2, plc3: __): Function<
974 T extends Function3<infer T1, T2, infer T3, infer R> ? Function2<T1, T3, R> :
975 any
976 >;
977 /**
978 * @see _.partialRight
979 */
980 partialRight<T1, T2>(arg1: T1, arg2: T2, plc3: __): Function<
981 T extends Function3<T1, T2, infer T3, infer R> ? Function1<T3, R> :
982 any
983 >;
984 /**
985 * @see _.partialRight
986 */
987 partialRight<T3>(arg3: T3): Function<
988 T extends Function3<infer T1, infer T2, T3, infer R> ? Function2<T1, T2, R> :
989 any
990 >;
991 /**
992 * @see _.partialRight
993 */
994 partialRight<T1, T3>(arg1: T1, plc2: __, arg3: T3): Function<
995 T extends Function3<T1, infer T2, T3, infer R> ? Function1<T2, R> :
996 any
997 >;
998 /**
999 * @see _.partialRight
1000 */
1001 partialRight<T2, T3>(arg2: T2, arg3: T3): Function<
1002 T extends Function3<infer T1, T2, T3, infer R> ? Function1<T1, R> :
1003 any
1004 >;
1005 /**
1006 * @see _.partialRight
1007 */
1008 partialRight<T1>(arg1: T1, plc2: __, plc3: __, plc4: __): Function<
1009 T extends Function4<T1, infer T2, infer T3, infer T4, infer R> ? Function3<T2, T3, T4, R> :
1010 any
1011 >;
1012 /**
1013 * @see _.partialRight
1014 */
1015 partialRight<T2>(arg2: T2, plc3: __, plc4: __): Function<
1016 T extends Function4<infer T1, T2, infer T3, infer T4, infer R> ? Function3<T1, T3, T4, R> :
1017 any
1018 >;
1019 /**
1020 * @see _.partialRight
1021 */
1022 partialRight<T1, T2>(arg1: T1, arg2: T2, plc3: __, plc4: __): Function<
1023 T extends Function4<T1, T2, infer T3, infer T4, infer R> ? Function2<T3, T4, R> :
1024 any
1025 >;
1026 /**
1027 * @see _.partialRight
1028 */
1029 partialRight<T3>(arg3: T3, plc4: __): Function<
1030 T extends Function4<infer T1, infer T2, T3, infer T4, infer R> ? Function3<T1, T2, T4, R> :
1031 any
1032 >;
1033 /**
1034 * @see _.partialRight
1035 */
1036 partialRight<T1, T3>(arg1: T1, plc2: __, arg3: T3, plc4: __): Function<
1037 T extends Function4<T1, infer T2, infer T3, infer T4, infer R> ? Function2<T2, T4, R> :
1038 any
1039 >;
1040 /**
1041 * @see _.partialRight
1042 */
1043 partialRight<T2, T3>(arg2: T2, arg3: T3, plc4: __): Function<
1044 T extends Function4<infer T1, T2, T3, infer T4, infer R> ? Function2<T1, T4, R> :
1045 any
1046 >;
1047 /**
1048 * @see _.partialRight
1049 */
1050 partialRight<T1, T2, T3>(arg1: T1, arg2: T2, arg3: T3, plc4: __): Function<
1051 T extends Function4<T1, T2, T3, infer T4, infer R> ? Function1<T4, R> :
1052 any
1053 >;
1054 /**
1055 * @see _.partialRight
1056 */
1057 partialRight<T4>(arg4: T4): Function<
1058 T extends Function4<infer T1, infer T2, infer T3, T4, infer R> ? Function3<T1, T2, T3, R> :
1059 any
1060 >;
1061 /**
1062 * @see _.partialRight
1063 */
1064 partialRight<T1, T4>(arg1: T1, plc2: __, plc3: __, arg4: T4): Function<
1065 T extends Function4<T1, infer T2, infer T3, T4, infer R> ? Function2<T2, T3, R> :
1066 any
1067 >;
1068 /**
1069 * @see _.partialRight
1070 */
1071 partialRight<T2, T4>(arg2: T2, plc3: __, arg4: T4): Function<
1072 T extends Function4<infer T1, T2, infer T3, T4, infer R> ? Function2<T1, T3, R> :
1073 any
1074 >;
1075 /**
1076 * @see _.partialRight
1077 */
1078 partialRight<T1, T2, T4>(arg1: T1, arg2: T2, plc3: __, arg4: T4): Function<
1079 T extends Function4<T1, T2, infer T3, T4, infer R> ? Function1<T3, R> :
1080 any
1081 >;
1082 /**
1083 * @see _.partialRight
1084 */
1085 partialRight<T3, T4>(arg3: T3, arg4: T4): Function<
1086 T extends Function4<infer T1, infer T2, T3, T4, infer R> ? Function2<T1, T2, R> :
1087 any
1088 >;
1089 /**
1090 * @see _.partialRight
1091 */
1092 partialRight<T1, T3, T4>(arg1: T1, plc2: __, arg3: T3, arg4: T4): Function<
1093 T extends Function4<T1, infer T2, T3, T4, infer R> ? Function1<T2, R> :
1094 any
1095 >;
1096 /**
1097 * @see _.partialRight
1098 */
1099 partialRight<T2, T3, T4>(arg2: T2, arg3: T3, arg4: T4): Function<
1100 T extends Function4<infer T1, T2, T3, T4, infer R> ? Function1<T1, R> :
1101 any
1102 >;
1103 /**
1104 * @see _.partialRight
1105 */
1106 partialRight<TS extends any[]>(...ts: TS): Function<T extends (...args: TS) => infer R ? () => R : any>;
1107 /**
1108 * @see _.partialRight
1109 */
1110 partialRight(): Function<T extends (...ts: any[]) => any ? T : any>;
1111 }
1112 interface FunctionChain<T extends (...args: any) => any> {
1113 /**
1114 * @see _.partialRight
1115 */
1116 partialRight<T1>(arg1: T1, plc2: __): FunctionChain<
1117 T extends Function2<T1, infer T2, infer R> ? Function1<T2, R> :
1118 any
1119 >;
1120 /**
1121 * @see _.partialRight
1122 */
1123 partialRight<T2>(arg2: T2): FunctionChain<
1124 T extends Function2<infer T1, T2, infer R> ? Function1<T1, R> : any
1125 >;
1126 /**
1127 * @see _.partialRight
1128 */
1129 partialRight<T1>(arg1: T1, plc2: __, plc3: __): FunctionChain<
1130 T extends Function3<T1, infer T2, infer T3, infer R> ? Function2<T2, T3, R> :
1131 any
1132 >;
1133 /**
1134 * @see _.partialRight
1135 */
1136 partialRight<T2>(arg2: T2, plc3: __): FunctionChain<
1137 T extends Function3<infer T1, T2, infer T3, infer R> ? Function2<T1, T3, R> :
1138 any
1139 >;
1140 /**
1141 * @see _.partialRight
1142 */
1143 partialRight<T1, T2>(arg1: T1, arg2: T2, plc3: __): FunctionChain<
1144 T extends Function3<T1, T2, infer T3, infer R> ? Function1<T3, R> :
1145 any
1146 >;
1147 /**
1148 * @see _.partialRight
1149 */
1150 partialRight<T3>(arg3: T3): FunctionChain<
1151 T extends Function3<infer T1, infer T2, T3, infer R> ? Function2<T1, T2, R> :
1152 any
1153 >;
1154 /**
1155 * @see _.partialRight
1156 */
1157 partialRight<T1, T3>(arg1: T1, plc2: __, arg3: T3): FunctionChain<
1158 T extends Function3<T1, infer T2, T3, infer R> ? Function1<T2, R> :
1159 any
1160 >;
1161 /**
1162 * @see _.partialRight
1163 */
1164 partialRight<T2, T3>(arg2: T2, arg3: T3): FunctionChain<
1165 T extends Function3<infer T1, T2, T3, infer R> ? Function1<T1, R> :
1166 any
1167 >;
1168 /**
1169 * @see _.partialRight
1170 */
1171 partialRight<T1>(arg1: T1, plc2: __, plc3: __, plc4: __): FunctionChain<
1172 T extends Function4<T1, infer T2, infer T3, infer T4, infer R> ? Function3<T2, T3, T4, R> :
1173 any
1174 >;
1175 /**
1176 * @see _.partialRight
1177 */
1178 partialRight<T2>(arg2: T2, plc3: __, plc4: __): FunctionChain<
1179 T extends Function4<infer T1, T2, infer T3, infer T4, infer R> ? Function3<T1, T3, T4, R> :
1180 any
1181 >;
1182 /**
1183 * @see _.partialRight
1184 */
1185 partialRight<T1, T2>(arg1: T1, arg2: T2, plc3: __, plc4: __): FunctionChain<
1186 T extends Function4<T1, T2, infer T3, infer T4, infer R> ? Function2<T3, T4, R> :
1187 any
1188 >;
1189 /**
1190 * @see _.partialRight
1191 */
1192 partialRight<T3>(arg3: T3, plc4: __): FunctionChain<
1193 T extends Function4<infer T1, infer T2, T3, infer T4, infer R> ? Function3<T1, T2, T4, R> :
1194 any
1195 >;
1196 /**
1197 * @see _.partialRight
1198 */
1199 partialRight<T1, T3>(arg1: T1, plc2: __, arg3: T3, plc4: __): FunctionChain<
1200 T extends Function4<T1, infer T2, infer T3, infer T4, infer R> ? Function2<T2, T4, R> :
1201 any
1202 >;
1203 /**
1204 * @see _.partialRight
1205 */
1206 partialRight<T2, T3>(arg2: T2, arg3: T3, plc4: __): FunctionChain<
1207 T extends Function4<infer T1, T2, T3, infer T4, infer R> ? Function2<T1, T4, R> :
1208 any
1209 >;
1210 /**
1211 * @see _.partialRight
1212 */
1213 partialRight<T1, T2, T3>(arg1: T1, arg2: T2, arg3: T3, plc4: __): FunctionChain<
1214 T extends Function4<T1, T2, T3, infer T4, infer R> ? Function1<T4, R> :
1215 any
1216 >;
1217 /**
1218 * @see _.partialRight
1219 */
1220 partialRight<T4>(arg4: T4): FunctionChain<
1221 T extends Function4<infer T1, infer T2, infer T3, T4, infer R> ? Function3<T1, T2, T3, R> :
1222 any
1223 >;
1224 /**
1225 * @see _.partialRight
1226 */
1227 partialRight<T1, T4>(arg1: T1, plc2: __, plc3: __, arg4: T4): FunctionChain<
1228 T extends Function4<T1, infer T2, infer T3, T4, infer R> ? Function2<T2, T3, R> :
1229 any
1230 >;
1231 /**
1232 * @see _.partialRight
1233 */
1234 partialRight<T2, T4>(arg2: T2, plc3: __, arg4: T4): FunctionChain<
1235 T extends Function4<infer T1, T2, infer T3, T4, infer R> ? Function2<T1, T3, R> :
1236 any
1237 >;
1238 /**
1239 * @see _.partialRight
1240 */
1241 partialRight<T1, T2, T4>(arg1: T1, arg2: T2, plc3: __, arg4: T4): FunctionChain<
1242 T extends Function4<T1, T2, infer T3, T4, infer R> ? Function1<T3, R> :
1243 any
1244 >;
1245 /**
1246 * @see _.partialRight
1247 */
1248 partialRight<T3, T4>(arg3: T3, arg4: T4): FunctionChain<
1249 T extends Function4<infer T1, infer T2, T3, T4, infer R> ? Function2<T1, T2, R> :
1250 any
1251 >;
1252 /**
1253 * @see _.partialRight
1254 */
1255 partialRight<T1, T3, T4>(arg1: T1, plc2: __, arg3: T3, arg4: T4): FunctionChain<
1256 T extends Function4<T1, infer T2, T3, T4, infer R> ? Function1<T2, R> :
1257 any
1258 >;
1259 /**
1260 * @see _.partialRight
1261 */
1262 partialRight<T2, T3, T4>(arg2: T2, arg3: T3, arg4: T4): FunctionChain<
1263 T extends Function4<infer T1, T2, T3, T4, infer R> ? Function1<T1, R> :
1264 any
1265 >;
1266 /**
1267 * @see _.partialRight
1268 */
1269 partialRight<TS extends any[]>(...ts: TS): FunctionChain<T extends (...args: TS) => infer R ? () => R : any>;
1270 /**
1271 * @see _.partialRight
1272 */
1273 partialRight(): FunctionChain<T extends (...ts: any[]) => any ? T : any>;
1274 }
1275 interface LoDashStatic {
1276 /**
1277 * Creates a function that invokes func with arguments arranged according to the specified indexes where the
1278 * argument value at the first index is provided as the first argument, the argument value at the second index
1279 * is provided as the second argument, and so on.
1280 * @param func The function to rearrange arguments for.
1281 * @param indexes The arranged argument indexes, specified as individual indexes or arrays of indexes.
1282 * @return Returns the new function.
1283 */
1284 rearg(func: (...args: any[]) => any, ...indexes: Array<Many<number>>): (...args: any[]) => any;
1285 }
1286 interface Function<T extends (...args: any) => any> {
1287 /**
1288 * @see _.rearg
1289 */
1290 rearg(...indexes: Array<Many<number>>): Function<(...args: any[]) => any>;
1291 }
1292 interface FunctionChain<T extends (...args: any) => any> {
1293 /**
1294 * @see _.rearg
1295 */
1296 rearg(...indexes: Array<Many<number>>): FunctionChain<(...args: any[]) => any>;
1297 }
1298 interface LoDashStatic {
1299 /**
1300 * Creates a function that invokes func with the this binding of the created function and arguments from start
1301 * and beyond provided as an array.
1302 *
1303 * Note: This method is based on the rest parameter.
1304 *
1305 * @param func The function to apply a rest parameter to.
1306 * @param start The start position of the rest parameter.
1307 * @return Returns the new function.
1308 */
1309 rest(func: (...args: any[]) => any, start?: number): (...args: any[]) => any;
1310 }
1311 interface Function<T extends (...args: any) => any> {
1312 /**
1313 * @see _.rest
1314 */
1315 rest(start?: number): Function<(...args: any[]) => any>;
1316 }
1317 interface FunctionChain<T extends (...args: any) => any> {
1318 /**
1319 * @see _.rest
1320 */
1321 rest(start?: number): FunctionChain<(...args: any[]) => any>;
1322 }
1323 interface LoDashStatic {
1324 /**
1325 * Creates a function that invokes func with the this binding of the created function and an array of arguments
1326 * much like Function#apply.
1327 *
1328 * Note: This method is based on the spread operator.
1329 *
1330 * @param func The function to spread arguments over.
1331 * @return Returns the new function.
1332 */
1333 spread<TResult>(func: (...args: any[]) => TResult, start?: number): (...args: any[]) => TResult;
1334 }
1335 interface Function<T extends (...args: any) => any> {
1336 /**
1337 * @see _.spread
1338 */
1339 spread(start?: number): Function<(...args: any[]) => ReturnType<T>>;
1340 }
1341 interface FunctionChain<T extends (...args: any) => any> {
1342 /**
1343 * @see _.spread
1344 */
1345 spread(start?: number): FunctionChain<(...args: any[]) => ReturnType<T>>;
1346 }
1347 interface ThrottleSettings {
1348 /**
1349 * @see _.leading
1350 */
1351 leading?: boolean | undefined;
1352 /**
1353 * @see _.trailing
1354 */
1355 trailing?: boolean | undefined;
1356 }
1357 type ThrottleSettingsLeading = (ThrottleSettings & { leading: true }) | Omit<ThrottleSettings, 'leading'>
1358 interface LoDashStatic {
1359 /**
1360 * Creates a throttled function that only invokes func at most once per every wait milliseconds. The throttled
1361 * function comes with a cancel method to cancel delayed invocations and a flush method to immediately invoke
1362 * them. Provide an options object to indicate that func should be invoked on the leading and/or trailing edge
1363 * of the wait timeout. Subsequent calls to the throttled function return the result of the last func call.
1364 *
1365 * Note: If leading and trailing options are true, func is invoked on the trailing edge of the timeout only if
1366 * the the throttled function is invoked more than once during the wait timeout.
1367 *
1368 * @param func The function to throttle.
1369 * @param wait The number of milliseconds to throttle invocations to.
1370 * @param options The options object.
1371 * @param options.leading Specify invoking on the leading edge of the timeout.
1372 * @param options.trailing Specify invoking on the trailing edge of the timeout.
1373 * @return Returns the new throttled function.
1374 */
1375 throttle<T extends (...args: any) => any>(func: T, wait?: number, options?: ThrottleSettingsLeading): DebouncedFuncLeading<T>;
1376 throttle<T extends (...args: any) => any>(func: T, wait?: number, options?: ThrottleSettings): DebouncedFunc<T>;
1377 }
1378 interface Function<T extends (...args: any) => any> {
1379 /**
1380 * @see _.throttle
1381 */
1382 throttle(
1383 wait?: number,
1384 options?: ThrottleSettingsLeading
1385 ): T extends (...args: any[]) => any ? Function<DebouncedFuncLeading<T>> : never;
1386 throttle(
1387 wait?: number,
1388 options?: ThrottleSettings
1389 ): T extends (...args: any[]) => any ? Function<DebouncedFunc<T>> : never;
1390 }
1391 interface FunctionChain<T extends (...args: any) => any> {
1392 /**
1393 * @see _.throttle
1394 */
1395 throttle(
1396 wait?: number,
1397 options?: ThrottleSettingsLeading
1398 ): T extends (...args: any[]) => any ? FunctionChain<DebouncedFuncLeading<T>> : never;
1399 throttle(
1400 wait?: number,
1401 options?: ThrottleSettings
1402 ): T extends (...args: any[]) => any ? FunctionChain<DebouncedFunc<T>> : never;
1403 }
1404 interface LoDashStatic {
1405 /**
1406 * Creates a function that accepts up to one argument, ignoring any
1407 * additional arguments.
1408 *
1409 * @category Function
1410 * @param func The function to cap arguments for.
1411 * @returns Returns the new function.
1412 * @example
1413 *
1414 * _.map(['6', '8', '10'], _.unary(parseInt));
1415 * // => [6, 8, 10]
1416 */
1417 unary<T, TResult>(func: (arg1: T, ...args: any[]) => TResult): (arg1: T) => TResult;
1418 }
1419 interface Function<T extends (...args: any) => any> {
1420 /**
1421 * @see _.unary
1422 */
1423 unary(): Function<(arg1: Parameters<T>['0']) => ReturnType<T>>;
1424 }
1425 interface FunctionChain<T extends (...args: any) => any> {
1426 /**
1427 * @see _.unary
1428 */
1429 unary(): FunctionChain<(arg1: Parameters<T>['0']) => ReturnType<T>>;
1430 }
1431 interface LoDashStatic {
1432 /**
1433 * Creates a function that provides value to the wrapper function as its first argument. Any additional
1434 * arguments provided to the function are appended to those provided to the wrapper function. The wrapper is
1435 * invoked with the this binding of the created function.
1436 *
1437 * @param value The value to wrap.
1438 * @param wrapper The wrapper function.
1439 * @return Returns the new function.
1440 */
1441 wrap<T, TArgs, TResult>(value: T, wrapper: (value: T, ...args: TArgs[]) => TResult): (...args: TArgs[]) => TResult;
1442 }
1443 interface LoDashImplicitWrapper<TValue> {
1444 /**
1445 * @see _.wrap
1446 */
1447 wrap<TArgs, TResult>(wrapper: (value: TValue, ...args: TArgs[]) => TResult): Function<(...args: TArgs[]) => TResult>;
1448 }
1449 interface LoDashExplicitWrapper<TValue> {
1450 /**
1451 * @see _.wrap
1452 */
1453 wrap<TArgs, TResult>(wrapper: (value: TValue, ...args: TArgs[]) => TResult): FunctionChain<(...args: TArgs[]) => TResult>;
1454 }
1455}