UNPKG

41.7 kBTypeScriptView Raw
1import _ = require("../index");
2declare module "../index" {
3 interface LoDashStatic {
4 /**
5 * Attempts to invoke func, returning either the result or the caught error object. Any additional arguments
6 * are provided to func when it’s invoked.
7 *
8 * @param func The function to attempt.
9 * @return Returns the func result or error object.
10 */
11 attempt<TResult>(func: (...args: any[]) => TResult, ...args: any[]): TResult | Error;
12 }
13 interface LoDashImplicitWrapper<TValue> {
14 /**
15 * @see _.attempt
16 */
17 attempt<TResult>(...args: any[]): TResult | Error;
18 }
19 interface LoDashExplicitWrapper<TValue> {
20 /**
21 * @see _.attempt
22 */
23 attempt<TResult>(...args: any[]): ExpChain<TResult | Error>;
24 }
25
26 interface LoDashStatic {
27 /**
28 * Binds methods of an object to the object itself, overwriting the existing method. Method names may be
29 * specified as individual arguments or as arrays of method names. If no method names are provided all
30 * enumerable function properties, own and inherited, of object are bound.
31 *
32 * Note: This method does not set the "length" property of bound functions.
33 *
34 * @param object The object to bind and assign the bound methods to.
35 * @param methodNames The object method names to bind, specified as individual method names or arrays of
36 * method names.
37 * @return Returns object.
38 */
39 bindAll<T>(object: T, ...methodNames: Array<Many<string>>): T;
40 }
41 interface LoDashImplicitWrapper<TValue> {
42 /**
43 * @see _.bindAll
44 */
45 bindAll(...methodNames: Array<Many<string>>): this;
46 }
47 interface LoDashExplicitWrapper<TValue> {
48 /**
49 * @see _.bindAll
50 */
51 bindAll(...methodNames: Array<Many<string>>): this;
52 }
53
54 interface LoDashStatic {
55 /**
56 * Creates a function that iterates over `pairs` and invokes the corresponding
57 * function of the first predicate to return truthy. The predicate-function
58 * pairs are invoked with the `this` binding and arguments of the created
59 * function.
60 *
61 * @since 4.0.0
62 * @category Util
63 * @param pairs The predicate-function pairs.
64 * @returns Returns the new composite function.
65 * @example
66 *
67 * var func = _.cond([
68 * [_.matches({ 'a': 1 }), _.constant('matches A')],
69 * [_.conforms({ 'b': _.isNumber }), _.constant('matches B')],
70 * [_.stubTrue, _.constant('no match')]
71 * ]);
72 *
73 * func({ 'a': 1, 'b': 2 });
74 * // => 'matches A'
75 *
76 * func({ 'a': 0, 'b': 1 });
77 * // => 'matches B'
78 *
79 * func({ 'a': '1', 'b': '2' });
80 * // => 'no match'
81 */
82 cond<T, R>(pairs: Array<CondPair<T, R>>): (Target: T) => R;
83 }
84
85 type ConformsPredicateObject<T> = {
86 [P in keyof T]: T[P] extends (arg: infer A) => any ? A : any
87 };
88 interface LoDashStatic {
89 /**
90 * Creates a function that invokes the predicate properties of `source` with the corresponding
91 * property values of a given object, returning true if all predicates return truthy, else false.
92 */
93 conforms<T>(source: ConformsPredicateObject<T>): (value: T) => boolean;
94 }
95 interface LoDashImplicitWrapper<TValue> {
96 /**
97 * @see _.conforms
98 */
99 conforms(): Function<(value: ConformsPredicateObject<TValue>) => boolean>;
100 }
101 interface LoDashExplicitWrapper<TValue> {
102 /**
103 * @see _.conforms
104 */
105 conforms(): FunctionChain<(value: ConformsPredicateObject<TValue>) => boolean>;
106 }
107
108 interface LoDashStatic {
109 /**
110 * Creates a function that returns value.
111 *
112 * @param value The value to return from the new function.
113 * @return Returns the new function.
114 */
115 constant<T>(value: T): () => T;
116 }
117 interface LoDashImplicitWrapper<TValue> {
118 /**
119 * @see _.constant
120 */
121 constant(): Function<() => TValue>;
122 }
123 interface LoDashExplicitWrapper<TValue> {
124 /**
125 * @see _.constant
126 */
127 constant(): FunctionChain<() => TValue>;
128 }
129
130 interface LoDashStatic {
131 /**
132 * Checks `value` to determine whether a default value should be returned in
133 * its place. The `defaultValue` is returned if `value` is `NaN`, `null`,
134 * or `undefined`.
135 *
136 * @param value The value to check.
137 * @param defaultValue The default value.
138 * @returns Returns the resolved value.
139 */
140 defaultTo<T>(value: T | null | undefined, defaultValue: T): T;
141 /**
142 * @see _.defaultTo
143 */
144 defaultTo<T, TDefault>(value: T | null | undefined, defaultValue: TDefault): T | TDefault;
145 }
146 interface LoDashImplicitWrapper<TValue> {
147 /**
148 * @see _.defaultTo
149 */
150 defaultTo(defaultValue: TValue): TValue;
151 /**
152 * @see _.defaultTo
153 */
154 defaultTo<TDefault>(defaultValue: TDefault): TValue extends null | undefined ? TDefault : TValue | TDefault;
155 }
156 interface LoDashExplicitWrapper<TValue> {
157 /**
158 * @see _.defaultTo
159 */
160 defaultTo(defaultValue: TValue): ExpChain<TValue>;
161 /**
162 * @see _.defaultTo
163 */
164 defaultTo<TDefault>(defaultValue: TDefault): ExpChain<TValue extends null | undefined ? TDefault : TValue | TDefault>;
165 }
166
167 interface LoDashStatic {
168 /**
169 * Creates a function that returns the result of invoking the provided functions with the this binding of the
170 * created function, where each successive invocation is supplied the return value of the previous.
171 *
172 * @param funcs Functions to invoke.
173 * @return Returns the new function.
174 */
175 flow<A extends any[], R1, R2, R3, R4, R5, R6, R7>(f1: (...args: A) => R1, f2: (a: R1) => R2, f3: (a: R2) => R3, f4: (a: R3) => R4, f5: (a: R4) => R5, f6: (a: R5) => R6, f7: (a: R6) => R7): (...args: A) => R7;
176 /**
177 * @see _.flow
178 */
179 flow<A extends any[], R1, R2, R3, R4, R5, R6, R7>(f1: (...args: A) => R1, f2: (a: R1) => R2, f3: (a: R2) => R3, f4: (a: R3) => R4, f5: (a: R4) => R5, f6: (a: R5) => R6, f7: (a: R6) => R7, ...func: Array<Many<(a: any) => any>>): (...args: A) => any;
180 /**
181 * @see _.flow
182 */
183 flow<A extends any[], R1, R2, R3, R4, R5, R6>(f1: (...args: A) => R1, f2: (a: R1) => R2, f3: (a: R2) => R3, f4: (a: R3) => R4, f5: (a: R4) => R5, f6: (a: R5) => R6): (...args: A) => R6;
184 /**
185 * @see _.flow
186 */
187 flow<A extends any[], R1, R2, R3, R4, R5>(f1: (...args: A) => R1, f2: (a: R1) => R2, f3: (a: R2) => R3, f4: (a: R3) => R4, f5: (a: R4) => R5): (...args: A) => R5;
188 /**
189 * @see _.flow
190 */
191 flow<A extends any[], R1, R2, R3, R4>(f1: (...args: A) => R1, f2: (a: R1) => R2, f3: (a: R2) => R3, f4: (a: R3) => R4): (...args: A) => R4;
192 /**
193 * @see _.flow
194 */
195 flow<A extends any[], R1, R2, R3>(f1: (...args: A) => R1, f2: (a: R1) => R2, f3: (a: R2) => R3): (...args: A) => R3;
196 /**
197 * @see _.flow
198 */
199 flow<A extends any[], R1, R2>(f1: (...args: A) => R1, f2: (a: R1) => R2): (...args: A) => R2;
200 /**
201 * @see _.flow
202 */
203 flow(...func: Array<Many<(...args: any[]) => any>>): (...args: any[]) => any;
204 }
205 interface Function<T extends (...arg: any) => any> {
206 /**
207 * @see _.flow
208 */
209 flow<R2, R3, R4, R5, R6, R7>(f2: (a: ReturnType<T>) => R2, f3: (a: R2) => R3, f4: (a: R3) => R4, f5: (a: R4) => R5, f6: (a: R5) => R6, f7: (a: R6) => R7): Function<(...args: Parameters<T>) => R7>;
210 /**
211 * @see _.flow
212 */
213 flow<R2, R3, R4, R5, R6, R7>(f2: (a: ReturnType<T>) => R2, f3: (a: R2) => R3, f4: (a: R3) => R4, f5: (a: R4) => R5, f6: (a: R5) => R6, f7: (a: R6) => R7, ...func: Array<Many<(a: any) => any>>): Function<(...args: Parameters<T>) => any>;
214 /**
215 * @see _.flow
216 */
217 flow<R2, R3, R4, R5, R6>(f2: (a: ReturnType<T>) => R2, f3: (a: R2) => R3, f4: (a: R3) => R4, f5: (a: R4) => R5, f6: (a: R5) => R6): Function<(...args: Parameters<T>) => R6>;
218 /**
219 * @see _.flow
220 */
221 flow<R2, R3, R4, R5>(f2: (a: ReturnType<T>) => R2, f3: (a: R2) => R3, f4: (a: R3) => R4, f5: (a: R4) => R5): Function<(...args: Parameters<T>) => R5>;
222 /**
223 * @see _.flow
224 */
225 flow<R2, R3, R4>(f2: (a: ReturnType<T>) => R2, f3: (a: R2) => R3, f4: (a: R3) => R4): Function<(...args: Parameters<T>) => R4>;
226 /**
227 * @see _.flow
228 */
229 flow<R2, R3>(f2: (a: ReturnType<T>) => R2, f3: (a: R2) => R3): Function<(...args: Parameters<T>) => R3>;
230 /**
231 * @see _.flow
232 */
233 flow<R2>(f2: (a: ReturnType<T>) => R2): Function<(...args: Parameters<T>) => R2>;
234 /**
235 * @see _.flow
236 */
237 flow(...func: Array<Many<(...args: any[]) => any>>): Function<(...args: any[]) => any>;
238 }
239 interface FunctionChain<T> {
240 /**
241 * @see _.flow
242 */
243 flow<R2, R3, R4, R5, R6, R7>(f2: (a: ReturnType<T>) => R2, f3: (a: R2) => R3, f4: (a: R3) => R4, f5: (a: R4) => R5, f6: (a: R5) => R6, f7: (a: R6) => R7): FunctionChain<(...args: Parameters<T>) => R7>;
244 /**
245 * @see _.flow
246 */
247 flow<R2, R3, R4, R5, R6, R7>(f2: (a: ReturnType<T>) => R2, f3: (a: R2) => R3, f4: (a: R3) => R4, f5: (a: R4) => R5, f6: (a: R5) => R6, f7: (a: R6) => R7, ...func: Array<Many<(a: any) => any>>): FunctionChain<(...args: Parameters<T>) => any>;
248 /**
249 * @see _.flow
250 */
251 flow<R2, R3, R4, R5, R6>(f2: (a: ReturnType<T>) => R2, f3: (a: R2) => R3, f4: (a: R3) => R4, f5: (a: R4) => R5, f6: (a: R5) => R6): FunctionChain<(...args: Parameters<T>) => R6>;
252 /**
253 * @see _.flow
254 */
255 flow<R2, R3, R4, R5>(f2: (a: ReturnType<T>) => R2, f3: (a: R2) => R3, f4: (a: R3) => R4, f5: (a: R4) => R5): FunctionChain<(...args: Parameters<T>) => R5>;
256 /**
257 * @see _.flow
258 */
259 flow<R2, R3, R4>(f2: (a: ReturnType<T>) => R2, f3: (a: R2) => R3, f4: (a: R3) => R4): FunctionChain<(...args: Parameters<T>) => R4>;
260 /**
261 * @see _.flow
262 */
263 flow<R2, R3>(f2: (a: ReturnType<T>) => R2, f3: (a: R2) => R3): FunctionChain<(...args: Parameters<T>) => R3>;
264 /**
265 * @see _.flow
266 */
267 flow<R2>(f2: (a: ReturnType<T>) => R2): FunctionChain<(...args: Parameters<T>) => R2>;
268 /**
269 * @see _.flow
270 */
271 flow(...func: Array<Many<(...args: any[]) => any>>): FunctionChain<(...args: any[]) => any>;
272 }
273
274 interface LoDashStatic {
275 /**
276 * This method is like _.flow except that it creates a function that invokes the provided functions from right
277 * to left.
278 *
279 * @param funcs Functions to invoke.
280 * @return Returns the new function.
281 */
282 flowRight<A extends any[], R1, R2, R3, R4, R5, R6, R7>(f7: (a: R6) => R7, f6: (a: R5) => R6, f5: (a: R4) => R5, f4: (a: R3) => R4, f3: (a: R2) => R3, f2: (a: R1) => R2, f1: (...args: A) => R1): (...args: A) => R7;
283 /**
284 * @see _.flowRight
285 */
286 flowRight<A extends any[], R1, R2, R3, R4, R5, R6>(f6: (a: R5) => R6, f5: (a: R4) => R5, f4: (a: R3) => R4, f3: (a: R2) => R3, f2: (a: R1) => R2, f1: (...args: A) => R1): (...args: A) => R6;
287 /**
288 * @see _.flowRight
289 */
290 flowRight<A extends any[], R1, R2, R3, R4, R5>(f5: (a: R4) => R5, f4: (a: R3) => R4, f3: (a: R2) => R3, f2: (a: R1) => R2, f1: (...args: A) => R1): (...args: A) => R5;
291 /**
292 * @see _.flowRight
293 */
294 flowRight<A extends any[], R1, R2, R3, R4>(f4: (a: R3) => R4, f3: (a: R2) => R3, f2: (a: R1) => R2, f1: (...args: A) => R1): (...args: A) => R4;
295 /**
296 * @see _.flowRight
297 */
298 flowRight<A extends any[], R1, R2, R3>(f3: (a: R2) => R3, f2: (a: R1) => R2, f1: (...args: A) => R1): (...args: A) => R3;
299 /**
300 * @see _.flowRight
301 */
302 flowRight<A extends any[], R1, R2>(f2: (a: R1) => R2, f1: (...args: A) => R1): (...args: A) => R2;
303 /**
304 * @see _.flowRight
305 */
306 flowRight(...func: Array<Many<(...args: any[]) => any>>): (...args: any[]) => any;
307 }
308 interface Function<T> {
309 /**
310 * @see _.flowRight
311 */
312 flowRight<A extends any[], R1, R2, R3, R4, R5>(f6: (a: R5) => Parameters<T>["0"], f5: (a: R4) => R5, f4: (a: R3) => R4, f3: (a: R2) => R3, f2: (a: R1) => R2, f1: (...args: A) => R1): Function<(...args: A) => ReturnType<T>>;
313 /**
314 * @see _.flowRight
315 */
316 flowRight<A extends any[], R1, R2, R3, R4>(f5: (a: R4) => Parameters<T>["0"], f4: (a: R3) => R4, f3: (a: R2) => R3, f2: (a: R1) => R2, f1: (...args: A) => R1): Function<(...args: A) => ReturnType<T>>;
317 /**
318 * @see _.flowRight
319 */
320 flowRight<A extends any[], R1, R2, R3>(f4: (a: R3) => Parameters<T>["0"], f3: (a: R2) => R3, f2: (a: R1) => R2, f1: (...args: A) => R1): Function<(...args: A) => ReturnType<T>>;
321 /**
322 * @see _.flowRight
323 */
324 flowRight<A extends any[], R1, R2>(f3: (a: R2) => Parameters<T>["0"], f2: (a: R1) => R2, f1: (...args: A) => R1): Function<(...args: A) => ReturnType<T>>;
325 /**
326 * @see _.flowRight
327 */
328 flowRight<A extends any[], R1>(f2: (a: R1) => Parameters<T>["0"], f1: (...args: A) => R1): Function<(...args: A) => ReturnType<T>>;
329 /**
330 * @see _.flowRight
331 */
332 flowRight<A extends any[]>(f1: (...args: A) => Parameters<T>["0"]): Function<(...args: A) => ReturnType<T>>;
333 /**
334 * @see _.flowRight
335 */
336 flowRight(...func: Array<Many<(...args: any[]) => any>>): Function<(...args: any[]) => any>;
337 }
338 interface FunctionChain<T> {
339 /**
340 * @see _.flowRight
341 */
342 flowRight<A extends any[], R1, R2, R3, R4, R5>(f6: (a: R5) => Parameters<T>["0"], f5: (a: R4) => R5, f4: (a: R3) => R4, f3: (a: R2) => R3, f2: (a: R1) => R2, f1: (...args: A) => R1): FunctionChain<(...args: A) => ReturnType<T>>;
343 /**
344 * @see _.flowRight
345 */
346 flowRight<A extends any[], R1, R2, R3, R4>(f5: (a: R4) => Parameters<T>["0"], f4: (a: R3) => R4, f3: (a: R2) => R3, f2: (a: R1) => R2, f1: (...args: A) => R1): FunctionChain<(...args: A) => ReturnType<T>>;
347 /**
348 * @see _.flowRight
349 */
350 flowRight<A extends any[], R1, R2, R3>(f4: (a: R3) => Parameters<T>["0"], f3: (a: R2) => R3, f2: (a: R1) => R2, f1: (...args: A) => R1): FunctionChain<(...args: A) => ReturnType<T>>;
351 /**
352 * @see _.flowRight
353 */
354 flowRight<A extends any[], R1, R2>(f3: (a: R2) => Parameters<T>["0"], f2: (a: R1) => R2, f1: (...args: A) => R1): FunctionChain<(...args: A) => ReturnType<T>>;
355 /**
356 * @see _.flowRight
357 */
358 flowRight<A extends any[], R1>(f2: (a: R1) => Parameters<T>["0"], f1: (...args: A) => R1): FunctionChain<(...args: A) => ReturnType<T>>;
359 /**
360 * @see _.flowRight
361 */
362 flowRight<A extends any[]>(f1: (...args: A) => Parameters<T>["0"]): FunctionChain<(...args: A) => ReturnType<T>>;
363 /**
364 * @see _.flowRight
365 */
366 flowRight(...func: Array<Many<(...args: any[]) => any>>): FunctionChain<(...args: any[]) => any>;
367 }
368
369 interface LoDashStatic {
370 /**
371 * This method returns the first argument provided to it.
372 *
373 * @param value Any value.
374 * @return Returns value.
375 */
376 identity<T>(value: T): T;
377 /**
378 * @see _.identity
379 */
380 identity(): undefined;
381 }
382 interface LoDashImplicitWrapper<TValue> {
383 /**
384 * @see _.identity
385 */
386 identity(): TValue;
387 }
388 interface LoDashExplicitWrapper<TValue> {
389 /**
390 * @see _.identity
391 */
392 identity(): this;
393 }
394
395 interface LoDashStatic {
396 /**
397 * Creates a function that invokes `func` with the arguments of the created
398 * function. If `func` is a property name the created callback returns the
399 * property value for a given element. If `func` is an object the created
400 * callback returns `true` for elements that contain the equivalent object properties, otherwise it returns `false`.
401 *
402 * @category Util
403 * @param [func=_.identity] The value to convert to a callback.
404 * @returns Returns the callback.
405 * @example
406 *
407 * var users = [
408 * { 'user': 'barney', 'age': 36 },
409 * { 'user': 'fred', 'age': 40 }
410 * ];
411 *
412 * // create custom iteratee shorthands
413 * _.iteratee = _.wrap(_.iteratee, function(callback, func) {
414 * var p = /^(\S+)\s*([<>])\s*(\S+)$/.exec(func);
415 * return !p ? callback(func) : function(object) {
416 * return (p[2] == '>' ? object[p[1]] > p[3] : object[p[1]] < p[3]);
417 * };
418 * });
419 *
420 * _.filter(users, 'age > 36');
421 * // => [{ 'user': 'fred', 'age': 40 }]
422 */
423 iteratee<TFunction extends (...args: any[]) => any>(func: TFunction): TFunction;
424 /**
425 * @see _.iteratee
426 */
427 iteratee(func: string | object): (...args: any[]) => any;
428 }
429 interface Function<T extends (...args: any) => any> {
430 /**
431 * @see _.iteratee
432 */
433 iteratee(): Function<T>;
434 }
435 interface Collection<T> {
436 /**
437 * @see _.iteratee
438 */
439 iteratee(): Function<(o: object) => boolean>;
440 }
441 interface Object<T> {
442 /**
443 * @see _.iteratee
444 */
445 iteratee(): Function<(o: T) => boolean>;
446 }
447 interface String {
448 /**
449 * @see _.iteratee
450 */
451 iteratee(): Function<(o: object) => any>;
452 }
453 interface FunctionChain<T extends (...args: any) => any> {
454 /**
455 * @see _.iteratee
456 */
457 iteratee(): FunctionChain<T>;
458 }
459 interface CollectionChain<T> {
460 /**
461 * @see _.iteratee
462 */
463 iteratee(): FunctionChain<(o: object) => boolean>;
464 }
465 interface ObjectChain<T> {
466 /**
467 * @see _.iteratee
468 */
469 iteratee(): FunctionChain<(o: T) => boolean>;
470 }
471 interface StringChain {
472 /**
473 * @see _.iteratee
474 */
475 iteratee(): FunctionChain<(o: object) => any>;
476 }
477 interface StringNullableChain {
478 /**
479 * @see _.iteratee
480 */
481 iteratee(): FunctionChain<(o: object) => any>;
482 }
483
484 interface LoDashStatic {
485 /**
486 * Creates a function that performs a deep comparison between a given object and source, returning true if the
487 * given object has equivalent property values, else false.
488 *
489 * Note: This method supports comparing arrays, booleans, Date objects, numbers, Object objects, regexes, and
490 * strings. Objects are compared by their own, not inherited, enumerable properties. For comparing a single own
491 * or inherited property value see _.matchesProperty.
492 *
493 * @param source The object of property values to match.
494 * @return Returns the new function.
495 */
496 matches<T>(source: T): (value: any) => boolean;
497 /**
498 * @see _.matches
499 */
500 matches<T, V>(source: T): (value: V) => boolean;
501 }
502 interface LoDashImplicitWrapper<TValue> {
503 /**
504 * @see _.matches
505 */
506 matches<V>(): Function<(value: V) => boolean>;
507 }
508 interface LoDashExplicitWrapper<TValue> {
509 /**
510 * @see _.matches
511 */
512 matches<V>(): FunctionChain<(value: V) => boolean>;
513 }
514
515 interface LoDashStatic {
516 /**
517 * Creates a function that compares the property value of path on a given object to value.
518 *
519 * Note: This method supports comparing arrays, booleans, Date objects, numbers, Object objects, regexes, and
520 * strings. Objects are compared by their own, not inherited, enumerable properties.
521 *
522 * @param path The path of the property to get.
523 * @param srcValue The value to match.
524 * @return Returns the new function.
525 */
526 matchesProperty<T>(path: PropertyPath, srcValue: T): (value: any) => boolean;
527 /**
528 * @see _.matchesProperty
529 */
530 matchesProperty<T, V>(path: PropertyPath, srcValue: T): (value: V) => boolean;
531 }
532 interface LoDashImplicitWrapper<TValue> {
533 /**
534 * @see _.matchesProperty
535 */
536 matchesProperty<SrcValue>(srcValue: SrcValue): Function<(value: any) => boolean>;
537 /**
538 * @see _.matchesProperty
539 */
540 matchesProperty<SrcValue, Value>(srcValue: SrcValue): Function<(value: Value) => boolean>;
541 }
542 interface LoDashExplicitWrapper<TValue> {
543 /**
544 * @see _.matchesProperty
545 */
546 matchesProperty<SrcValue>(srcValue: SrcValue): FunctionChain<(value: any) => boolean>;
547 /**
548 * @see _.matchesProperty
549 */
550 matchesProperty<SrcValue, Value>(srcValue: SrcValue): FunctionChain<(value: Value) => boolean>;
551 }
552
553 interface LoDashStatic {
554 /**
555 * Creates a function that invokes the method at path on a given object. Any additional arguments are provided
556 * to the invoked method.
557 *
558 * @param path The path of the method to invoke.
559 * @param args The arguments to invoke the method with.
560 * @return Returns the new function.
561 */
562 method(path: PropertyPath, ...args: any[]): (object: any) => any;
563 }
564 interface LoDashImplicitWrapper<TValue> {
565 /**
566 * @see _.method
567 */
568 method(...args: any[]): Function<(object: any) => any>;
569 }
570 interface LoDashExplicitWrapper<TValue> {
571 /**
572 * @see _.method
573 */
574 method(...args: any[]): FunctionChain<(object: any) => any>;
575 }
576
577 interface LoDashStatic {
578 /**
579 * The opposite of _.method; this method creates a function that invokes the method at a given path on object.
580 * Any additional arguments are provided to the invoked method.
581 *
582 * @param object The object to query.
583 * @param args The arguments to invoke the method with.
584 * @return Returns the new function.
585 */
586 methodOf(object: object, ...args: any[]): (path: PropertyPath) => any;
587 }
588 interface LoDashImplicitWrapper<TValue> {
589 /**
590 * @see _.methodOf
591 */
592 methodOf(...args: any[]): LoDashImplicitWrapper<(path: PropertyPath) => any>;
593 }
594 interface LoDashExplicitWrapper<TValue> {
595 /**
596 * @see _.methodOf
597 */
598 methodOf(...args: any[]): LoDashExplicitWrapper<(path: PropertyPath) => any>;
599 }
600
601 interface MixinOptions {
602 /**
603 * @see _.chain
604 */
605 chain?: boolean | undefined;
606 }
607 interface LoDashStatic {
608 /**
609 * Adds all own enumerable function properties of a source object to the destination object. If object is a
610 * function then methods are added to its prototype as well.
611 *
612 * Note: Use _.runInContext to create a pristine lodash function to avoid conflicts caused by modifying
613 * the original.
614 *
615 * @param object The destination object.
616 * @param source The object of functions to add.
617 * @param options The options object.
618 * @param options.chain Specify whether the functions added are chainable.
619 * @return Returns object.
620 */
621 mixin<TObject>(object: TObject, source: Dictionary<(...args: any[]) => any>, options?: MixinOptions): TObject;
622 /**
623 * @see _.mixin
624 */
625 mixin<TResult>(source: Dictionary<(...args: any[]) => any>, options?: MixinOptions): LoDashStatic;
626 }
627 interface LoDashImplicitWrapper<TValue> {
628 /**
629 * @see _.mixin
630 */
631 mixin(source: Dictionary<(...args: any[]) => any>, options?: MixinOptions): this;
632 /**
633 * @see _.mixin
634 */
635 mixin(options?: MixinOptions): LoDashImplicitWrapper<LoDashStatic>;
636 }
637 interface LoDashExplicitWrapper<TValue> {
638 /**
639 * @see _.mixin
640 */
641 mixin(source: Dictionary<(...args: any[]) => any>, options?: MixinOptions): this;
642 /**
643 * @see _.mixin
644 */
645 mixin(options?: MixinOptions): LoDashExplicitWrapper<LoDashStatic>;
646 }
647
648 interface LoDashStatic {
649 /**
650 * Reverts the _ variable to its previous value and returns a reference to the lodash function.
651 *
652 * @return Returns the lodash function.
653 */
654 noConflict(): typeof _;
655 }
656 interface LoDashImplicitWrapper<TValue> {
657 /**
658 * @see _.noConflict
659 */
660 noConflict(): typeof _;
661 }
662 interface LoDashExplicitWrapper<TValue> {
663 /**
664 * @see _.noConflict
665 */
666 noConflict(): LoDashExplicitWrapper<typeof _>;
667 }
668
669 interface LoDashStatic {
670 /**
671 * A no-operation function that returns undefined regardless of the arguments it receives.
672 *
673 * @return undefined
674 */
675 noop(...args: any[]): void;
676 }
677 interface LoDashImplicitWrapper<TValue> {
678 /**
679 * @see _.noop
680 */
681 noop(...args: any[]): void;
682 }
683 interface LoDashExplicitWrapper<TValue> {
684 /**
685 * @see _.noop
686 */
687 noop(...args: any[]): PrimitiveChain<undefined>;
688 }
689
690 interface LoDashStatic {
691 /**
692 * Creates a function that returns its nth argument.
693 *
694 * @param n The index of the argument to return.
695 * @return Returns the new function.
696 */
697 nthArg(n?: number): (...args: any[]) => any;
698 }
699 interface LoDashImplicitWrapper<TValue> {
700 /**
701 * @see _.nthArg
702 */
703 nthArg(): Function<(...args: any[]) => any>;
704 }
705 interface LoDashExplicitWrapper<TValue> {
706 /**
707 * @see _.nthArg
708 */
709 nthArg(): FunctionChain<(...args: any[]) => any>;
710 }
711
712 interface LoDashStatic {
713 /**
714 * Creates a function that invokes iteratees with the arguments provided to the created function and returns
715 * their results.
716 *
717 * @param iteratees The iteratees to invoke.
718 * @return Returns the new function.
719 */
720 over<TResult>(...iteratees: Array<Many<(...args: any[]) => TResult>>): (...args: any[]) => TResult[];
721 }
722 interface Collection<T> {
723 /**
724 * @see _.over
725 */
726 over<TResult>(...iteratees: Array<Many<(...args: any[]) => TResult>>): Function<(...args: any[]) => TResult[]>;
727 }
728 interface Function<T> {
729 /**
730 * @see _.over
731 */
732 over<TResult>(...iteratees: Array<Many<(...args: any[]) => TResult>>): Function<(...args: any[]) => Array<ReturnType<T> | TResult>>;
733 }
734 interface CollectionChain<T> {
735 /**
736 * @see _.over
737 */
738 over<TResult>(...iteratees: Array<Many<(...args: any[]) => TResult>>): FunctionChain<(...args: any[]) => TResult[]>;
739 }
740 interface FunctionChain<T> {
741 /**
742 * @see _.over
743 */
744 over<TResult>(...iteratees: Array<Many<(...args: any[]) => TResult>>): FunctionChain<(...args: any[]) => Array<ReturnType<T> | TResult>>;
745 }
746
747 interface LoDashStatic {
748 /**
749 * Creates a function that checks if all of the predicates return truthy when invoked with the arguments
750 * provided to the created function.
751 *
752 * @param predicates The predicates to check.
753 * @return Returns the new function.
754 */
755 overEvery<T, Result1 extends T, Result2 extends T>(...predicates: [
756 (arg: T) => arg is Result1,
757 (arg: T) => arg is Result2
758 ]): (arg: T) => arg is Result1 & Result2;
759 overEvery<T>(...predicates: Array<Many<(...args: T[]) => boolean>>): (...args: T[]) => boolean;
760 }
761 interface Collection<T> {
762 /**
763 * @see _.overEvery
764 */
765 overEvery<TArgs>(...iteratees: Array<Many<(...args: TArgs[]) => boolean>>): Function<(...args: TArgs[]) => boolean>;
766 }
767 interface Function<T> {
768 /**
769 * @see _.overEvery
770 */
771 overEvery<TArgs>(...iteratees: Array<Many<(...args: TArgs[]) => boolean>>): Function<(...args: Parameters<T> | TArgs[]) => boolean>;
772 }
773 interface CollectionChain<T> {
774 /**
775 * @see _.overEvery
776 */
777 overEvery<TArgs>(...iteratees: Array<Many<(...args: TArgs[]) => boolean>>): FunctionChain<(...args: TArgs[]) => boolean>;
778 }
779 interface FunctionChain<T> {
780 /**
781 * @see _.overEvery
782 */
783 overEvery<TArgs>(...iteratees: Array<Many<(...args: TArgs[]) => boolean>>): FunctionChain<(...args: Parameters<T> | TArgs[]) => boolean>;
784 }
785
786 interface LoDashStatic {
787 /**
788 * Creates a function that checks if any of the predicates return truthy when invoked with the arguments
789 * provided to the created function.
790 *
791 * @param predicates The predicates to check.
792 * @return Returns the new function.
793 */
794 overSome<T, Result1 extends T, Result2 extends T>(...predicates: [
795 (arg: T) => arg is Result1,
796 (arg: T) => arg is Result2
797 ]): (arg: T) => arg is Result1 | Result2;
798 overSome<T>(...predicates: Array<Many<(...args: T[]) => boolean>>): (...args: T[]) => boolean;
799 }
800 interface Collection<T> {
801 /**
802 * @see _.overSome
803 */
804 overSome<TArgs>(...iteratees: Array<Many<(...args: TArgs[]) => boolean>>): Function<(...args: TArgs[]) => boolean>;
805 }
806 interface Function<T> {
807 /**
808 * @see _.overSome
809 */
810 overSome<TArgs>(...iteratees: Array<Many<(...args: TArgs[]) => boolean>>): Function<(...args: Parameters<T> | TArgs[]) => boolean>;
811 }
812 interface CollectionChain<T> {
813 /**
814 * @see _.overSome
815 */
816 overSome<TArgs>(...iteratees: Array<Many<(...args: TArgs[]) => boolean>>): FunctionChain<(...args: TArgs[]) => boolean>;
817 }
818 interface FunctionChain<T> {
819 /**
820 * @see _.overSome
821 */
822 overSome<TArgs>(...iteratees: Array<Many<(...args: TArgs[]) => boolean>>): FunctionChain<(...args: Parameters<T> | TArgs[]) => boolean>;
823 }
824
825 interface LoDashStatic {
826 /**
827 * Creates a function that returns the property value at path on a given object.
828 *
829 * @param path The path of the property to get.
830 * @return Returns the new function.
831 */
832 property<TObj, TResult>(path: PropertyPath): (obj: TObj) => TResult;
833 }
834 interface LoDashImplicitWrapper<TValue> {
835 /**
836 * @see _.property
837 */
838 property<TObj, TResult>(): Function<(obj: TObj) => TResult>;
839 }
840 interface LoDashExplicitWrapper<TValue> {
841 /**
842 * @see _.property
843 */
844 property<TObj, TResult>(): FunctionChain<(obj: TObj) => TResult>;
845 }
846
847 interface LoDashStatic {
848 /**
849 * The opposite of _.property; this method creates a function that returns the property value at a given path
850 * on object.
851 *
852 * @param object The object to query.
853 * @return Returns the new function.
854 */
855 propertyOf<T extends {}>(object: T): (path: PropertyPath) => any;
856 }
857 interface LoDashImplicitWrapper<TValue> {
858 /**
859 * @see _.propertyOf
860 */
861 propertyOf(): LoDashImplicitWrapper<(path: PropertyPath) => any>;
862 }
863 interface LoDashExplicitWrapper<TValue> {
864 /**
865 * @see _.propertyOf
866 */
867 propertyOf(): LoDashExplicitWrapper<(path: PropertyPath) => any>;
868 }
869
870 interface LoDashStatic {
871 /**
872 * Creates an array of numbers (positive and/or negative) progressing from start up to, but not including, end.
873 * If end is not specified it’s set to start with start then set to 0. If end is less than start a zero-length
874 * range is created unless a negative step is specified.
875 *
876 * @param start The start of the range.
877 * @param end The end of the range.
878 * @param step The value to increment or decrement by.
879 * @return Returns a new range array.
880 */
881 range(start: number, end?: number, step?: number): number[];
882 /**
883 * @see _.range
884 */
885 range(end: number, index: string | number, guard: object): number[];
886 }
887 interface LoDashImplicitWrapper<TValue> {
888 /**
889 * @see _.range
890 */
891 range(end?: number, step?: number): Collection<number>;
892 }
893 interface LoDashExplicitWrapper<TValue> {
894 /**
895 * @see _.range
896 */
897 range(end?: number, step?: number): CollectionChain<number>;
898 }
899
900 interface LoDashStatic {
901 /**
902 * This method is like `_.range` except that it populates values in
903 * descending order.
904 *
905 * @category Util
906 * @param start The start of the range.
907 * @param end The end of the range.
908 * @param step The value to increment or decrement by.
909 * @returns Returns the new array of numbers.
910 * @example
911 *
912 * _.rangeRight(4);
913 * // => [3, 2, 1, 0]
914 *
915 * _.rangeRight(-4);
916 * // => [-3, -2, -1, 0]
917 *
918 * _.rangeRight(1, 5);
919 * // => [4, 3, 2, 1]
920 *
921 * _.rangeRight(0, 20, 5);
922 * // => [15, 10, 5, 0]
923 *
924 * _.rangeRight(0, -4, -1);
925 * // => [-3, -2, -1, 0]
926 *
927 * _.rangeRight(1, 4, 0);
928 * // => [1, 1, 1]
929 *
930 * _.rangeRight(0);
931 * // => []
932 */
933 rangeRight(start: number, end?: number, step?: number): number[];
934 /**
935 * @see _.rangeRight
936 */
937 rangeRight(end: number, index: string | number, guard: object): number[];
938 }
939 interface LoDashImplicitWrapper<TValue> {
940 /**
941 * @see _.rangeRight
942 */
943 rangeRight(end?: number, step?: number): Collection<number>;
944 }
945 interface LoDashExplicitWrapper<TValue> {
946 /**
947 * @see _.rangeRight
948 */
949 rangeRight(end?: number, step?: number): CollectionChain<number>;
950 }
951
952 interface LoDashStatic {
953 /**
954 * Create a new pristine lodash function using the given context object.
955 *
956 * @param context The context object.
957 * @return Returns a new lodash function.
958 */
959 runInContext(context?: object): LoDashStatic;
960 }
961 interface LoDashImplicitWrapper<TValue> {
962 /**
963 * @see _.runInContext
964 */
965 runInContext(): LoDashStatic;
966 }
967
968 interface LoDashStatic {
969 /**
970 * This method returns a new empty array.
971 *
972 * @returns Returns the new empty array.
973 */
974 stubArray(): any[];
975 }
976 interface LoDashImplicitWrapper<TValue> {
977 /**
978 * @see _.stubArray
979 */
980 stubArray(): any[];
981 }
982 interface LoDashExplicitWrapper<TValue> {
983 /**
984 * @see _.stubArray
985 */
986 stubArray(): CollectionChain<any>;
987 }
988
989 interface LoDashStatic {
990 /**
991 * This method returns `false`.
992 *
993 * @returns Returns `false`.
994 */
995 stubFalse(): false;
996 }
997 interface LoDashImplicitWrapper<TValue> {
998 /**
999 * @see _.stubFalse
1000 */
1001 stubFalse(): false;
1002 }
1003 interface LoDashExplicitWrapper<TValue> {
1004 /**
1005 * @see _.stubFalse
1006 */
1007 stubFalse(): PrimitiveChain<false>;
1008 }
1009
1010 interface LoDashStatic {
1011 /**
1012 * This method returns a new empty object.
1013 *
1014 * @returns Returns the new empty object.
1015 */
1016 stubObject(): any;
1017 }
1018 interface LoDashImplicitWrapper<TValue> {
1019 /**
1020 * @see _.stubObject
1021 */
1022 stubObject(): any;
1023 }
1024 interface LoDashExplicitWrapper<TValue> {
1025 /**
1026 * @see _.stubObject
1027 */
1028 stubObject(): LoDashExplicitWrapper<any>;
1029 }
1030
1031 interface LoDashStatic {
1032 /**
1033 * This method returns an empty string.
1034 *
1035 * @returns Returns the empty string.
1036 */
1037 stubString(): string;
1038 }
1039 interface LoDashImplicitWrapper<TValue> {
1040 /**
1041 * @see _.stubString
1042 */
1043 stubString(): string;
1044 }
1045 interface LoDashExplicitWrapper<TValue> {
1046 /**
1047 * @see _.stubString
1048 */
1049 stubString(): StringChain;
1050 }
1051
1052 interface LoDashStatic {
1053 /**
1054 * This method returns `true`.
1055 *
1056 * @returns Returns `true`.
1057 */
1058 stubTrue(): true;
1059 }
1060 interface LoDashImplicitWrapper<TValue> {
1061 /**
1062 * @see _.stubTrue
1063 */
1064 stubTrue(): true;
1065 }
1066 interface LoDashExplicitWrapper<TValue> {
1067 /**
1068 * @see _.stubTrue
1069 */
1070 stubTrue(): PrimitiveChain<true>;
1071 }
1072
1073 interface LoDashStatic {
1074 /**
1075 * Invokes the iteratee function n times, returning an array of the results of each invocation. The iteratee
1076 * is invoked with one argument; (index).
1077 *
1078 * @param n The number of times to invoke iteratee.
1079 * @param iteratee The function invoked per iteration.
1080 * @return Returns the array of results.
1081 */
1082 times<TResult>(n: number, iteratee: (num: number) => TResult): TResult[];
1083 /**
1084 * @see _.times
1085 */
1086 times(n: number): number[];
1087 }
1088 interface LoDashImplicitWrapper<TValue> {
1089 /**
1090 * @see _.times
1091 */
1092 times<TResult>(iteratee: (num: number) => TResult): TResult[];
1093 /**
1094 * @see _.times
1095 */
1096 times(): number[];
1097 }
1098 interface LoDashExplicitWrapper<TValue> {
1099 /**
1100 * @see _.times
1101 */
1102 times<TResult>(iteratee: (num: number) => TResult): CollectionChain<TResult>;
1103 /**
1104 * @see _.times
1105 */
1106 times(): CollectionChain<number>;
1107 }
1108
1109 interface LoDashStatic {
1110 /**
1111 * Converts `value` to a property path array.
1112 *
1113 * @category Util
1114 * @param value The value to convert.
1115 * @returns Returns the new property path array.
1116 * @example
1117 *
1118 * _.toPath('a.b.c');
1119 * // => ['a', 'b', 'c']
1120 *
1121 * _.toPath('a[0].b.c');
1122 * // => ['a', '0', 'b', 'c']
1123 *
1124 * var path = ['a', 'b', 'c'],
1125 * newPath = _.toPath(path);
1126 *
1127 * console.log(newPath);
1128 * // => ['a', 'b', 'c']
1129 *
1130 * console.log(path === newPath);
1131 * // => false
1132 */
1133 toPath(value: any): string[];
1134 }
1135 interface LoDashImplicitWrapper<TValue> {
1136 /**
1137 * @see _.toPath
1138 */
1139 toPath(): Collection<string>;
1140 }
1141 interface LoDashExplicitWrapper<TValue> {
1142 /**
1143 * @see _.toPath
1144 */
1145 toPath(): CollectionChain<string>;
1146 }
1147
1148 interface LoDashStatic {
1149 /**
1150 * Generates a unique ID. If prefix is provided the ID is appended to it.
1151 *
1152 * @param prefix The value to prefix the ID with.
1153 * @return Returns the unique ID.
1154 */
1155 uniqueId(prefix?: string): string;
1156 }
1157 interface LoDashImplicitWrapper<TValue> {
1158 /**
1159 * @see _.uniqueId
1160 */
1161 uniqueId(): string;
1162 }
1163 interface LoDashExplicitWrapper<TValue> {
1164 /**
1165 * @see _.uniqueId
1166 */
1167 uniqueId(): StringChain;
1168 }
1169
1170 // stubTrue
1171
1172 interface LoDashStatic {
1173 /**
1174 * This method returns true.
1175 *
1176 * @return Returns true.
1177 */
1178 stubTrue(): true;
1179 }
1180
1181 interface LoDashImplicitWrapper<TValue> {
1182 /**
1183 * @see _.stubTrue
1184 */
1185 stubTrue(): true;
1186 }
1187
1188 interface LoDashExplicitWrapper<TValue> {
1189 /**
1190 * @see _.stubTrue
1191 */
1192 stubTrue(): LoDashExplicitWrapper<true>;
1193 }
1194
1195 // stubFalse
1196
1197 interface LoDashStatic {
1198 /**
1199 * This method returns false.
1200 *
1201 * @return Returns false.
1202 */
1203 stubFalse(): false;
1204 }
1205
1206 interface LoDashImplicitWrapper<TValue> {
1207 /**
1208 * @see _.stubFalse
1209 */
1210 stubFalse(): false;
1211 }
1212
1213 interface LoDashExplicitWrapper<TValue> {
1214 /**
1215 * @see _.stubFalse
1216 */
1217 stubFalse(): LoDashExplicitWrapper<false>;
1218 }
1219}