UNPKG

40.3 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;
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>(...predicates: Array<Many<(...args: T[]) => boolean>>): (...args: T[]) => boolean;
756 }
757 interface Collection<T> {
758 /**
759 * @see _.overEvery
760 */
761 overEvery<TArgs>(...iteratees: Array<Many<(...args: TArgs[]) => boolean>>): Function<(...args: TArgs[]) => boolean>;
762 }
763 interface Function<T> {
764 /**
765 * @see _.overEvery
766 */
767 overEvery<TArgs>(...iteratees: Array<Many<(...args: TArgs[]) => boolean>>): Function<(...args: Parameters<T> | TArgs[]) => boolean>;
768 }
769 interface CollectionChain<T> {
770 /**
771 * @see _.overEvery
772 */
773 overEvery<TArgs>(...iteratees: Array<Many<(...args: TArgs[]) => boolean>>): FunctionChain<(...args: TArgs[]) => boolean>;
774 }
775 interface FunctionChain<T> {
776 /**
777 * @see _.overEvery
778 */
779 overEvery<TArgs>(...iteratees: Array<Many<(...args: TArgs[]) => boolean>>): FunctionChain<(...args: Parameters<T> | TArgs[]) => boolean>;
780 }
781
782 interface LoDashStatic {
783 /**
784 * Creates a function that checks if any of the predicates return truthy when invoked with the arguments
785 * provided to the created function.
786 *
787 * @param predicates The predicates to check.
788 * @return Returns the new function.
789 */
790 overSome<T>(...predicates: Array<Many<(...args: T[]) => boolean>>): (...args: T[]) => boolean;
791 }
792 interface Collection<T> {
793 /**
794 * @see _.overSome
795 */
796 overSome<TArgs>(...iteratees: Array<Many<(...args: TArgs[]) => boolean>>): Function<(...args: TArgs[]) => boolean>;
797 }
798 interface Function<T> {
799 /**
800 * @see _.overSome
801 */
802 overSome<TArgs>(...iteratees: Array<Many<(...args: TArgs[]) => boolean>>): Function<(...args: Parameters<T> | TArgs[]) => boolean>;
803 }
804 interface CollectionChain<T> {
805 /**
806 * @see _.overSome
807 */
808 overSome<TArgs>(...iteratees: Array<Many<(...args: TArgs[]) => boolean>>): FunctionChain<(...args: TArgs[]) => boolean>;
809 }
810 interface FunctionChain<T> {
811 /**
812 * @see _.overSome
813 */
814 overSome<TArgs>(...iteratees: Array<Many<(...args: TArgs[]) => boolean>>): FunctionChain<(...args: Parameters<T> | TArgs[]) => boolean>;
815 }
816
817 interface LoDashStatic {
818 /**
819 * Creates a function that returns the property value at path on a given object.
820 *
821 * @param path The path of the property to get.
822 * @return Returns the new function.
823 */
824 property<TObj, TResult>(path: PropertyPath): (obj: TObj) => TResult;
825 }
826 interface LoDashImplicitWrapper<TValue> {
827 /**
828 * @see _.property
829 */
830 property<TObj, TResult>(): Function<(obj: TObj) => TResult>;
831 }
832 interface LoDashExplicitWrapper<TValue> {
833 /**
834 * @see _.property
835 */
836 property<TObj, TResult>(): FunctionChain<(obj: TObj) => TResult>;
837 }
838
839 interface LoDashStatic {
840 /**
841 * The opposite of _.property; this method creates a function that returns the property value at a given path
842 * on object.
843 *
844 * @param object The object to query.
845 * @return Returns the new function.
846 */
847 propertyOf<T extends {}>(object: T): (path: PropertyPath) => any;
848 }
849 interface LoDashImplicitWrapper<TValue> {
850 /**
851 * @see _.propertyOf
852 */
853 propertyOf(): LoDashImplicitWrapper<(path: PropertyPath) => any>;
854 }
855 interface LoDashExplicitWrapper<TValue> {
856 /**
857 * @see _.propertyOf
858 */
859 propertyOf(): LoDashExplicitWrapper<(path: PropertyPath) => any>;
860 }
861
862 interface LoDashStatic {
863 /**
864 * Creates an array of numbers (positive and/or negative) progressing from start up to, but not including, end.
865 * 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
866 * range is created unless a negative step is specified.
867 *
868 * @param start The start of the range.
869 * @param end The end of the range.
870 * @param step The value to increment or decrement by.
871 * @return Returns a new range array.
872 */
873 range(start: number, end?: number, step?: number): number[];
874 /**
875 * @see _.range
876 */
877 range(end: number, index: string | number, guard: object): number[];
878 }
879 interface LoDashImplicitWrapper<TValue> {
880 /**
881 * @see _.range
882 */
883 range(end?: number, step?: number): Collection<number>;
884 }
885 interface LoDashExplicitWrapper<TValue> {
886 /**
887 * @see _.range
888 */
889 range(end?: number, step?: number): CollectionChain<number>;
890 }
891
892 interface LoDashStatic {
893 /**
894 * This method is like `_.range` except that it populates values in
895 * descending order.
896 *
897 * @category Util
898 * @param start The start of the range.
899 * @param end The end of the range.
900 * @param step The value to increment or decrement by.
901 * @returns Returns the new array of numbers.
902 * @example
903 *
904 * _.rangeRight(4);
905 * // => [3, 2, 1, 0]
906 *
907 * _.rangeRight(-4);
908 * // => [-3, -2, -1, 0]
909 *
910 * _.rangeRight(1, 5);
911 * // => [4, 3, 2, 1]
912 *
913 * _.rangeRight(0, 20, 5);
914 * // => [15, 10, 5, 0]
915 *
916 * _.rangeRight(0, -4, -1);
917 * // => [-3, -2, -1, 0]
918 *
919 * _.rangeRight(1, 4, 0);
920 * // => [1, 1, 1]
921 *
922 * _.rangeRight(0);
923 * // => []
924 */
925 rangeRight(start: number, end?: number, step?: number): number[];
926 /**
927 * @see _.rangeRight
928 */
929 rangeRight(end: number, index: string | number, guard: object): number[];
930 }
931 interface LoDashImplicitWrapper<TValue> {
932 /**
933 * @see _.rangeRight
934 */
935 rangeRight(end?: number, step?: number): Collection<number>;
936 }
937 interface LoDashExplicitWrapper<TValue> {
938 /**
939 * @see _.rangeRight
940 */
941 rangeRight(end?: number, step?: number): CollectionChain<number>;
942 }
943
944 interface LoDashStatic {
945 /**
946 * Create a new pristine lodash function using the given context object.
947 *
948 * @param context The context object.
949 * @return Returns a new lodash function.
950 */
951 runInContext(context?: object): LoDashStatic;
952 }
953 interface LoDashImplicitWrapper<TValue> {
954 /**
955 * @see _.runInContext
956 */
957 runInContext(): LoDashStatic;
958 }
959
960 interface LoDashStatic {
961 /**
962 * This method returns a new empty array.
963 *
964 * @returns Returns the new empty array.
965 */
966 stubArray(): any[];
967 }
968 interface LoDashImplicitWrapper<TValue> {
969 /**
970 * @see _.stubArray
971 */
972 stubArray(): any[];
973 }
974 interface LoDashExplicitWrapper<TValue> {
975 /**
976 * @see _.stubArray
977 */
978 stubArray(): CollectionChain<any>;
979 }
980
981 interface LoDashStatic {
982 /**
983 * This method returns `false`.
984 *
985 * @returns Returns `false`.
986 */
987 stubFalse(): false;
988 }
989 interface LoDashImplicitWrapper<TValue> {
990 /**
991 * @see _.stubFalse
992 */
993 stubFalse(): false;
994 }
995 interface LoDashExplicitWrapper<TValue> {
996 /**
997 * @see _.stubFalse
998 */
999 stubFalse(): PrimitiveChain<false>;
1000 }
1001
1002 interface LoDashStatic {
1003 /**
1004 * This method returns a new empty object.
1005 *
1006 * @returns Returns the new empty object.
1007 */
1008 stubObject(): any;
1009 }
1010 interface LoDashImplicitWrapper<TValue> {
1011 /**
1012 * @see _.stubObject
1013 */
1014 stubObject(): any;
1015 }
1016 interface LoDashExplicitWrapper<TValue> {
1017 /**
1018 * @see _.stubObject
1019 */
1020 stubObject(): LoDashExplicitWrapper<any>;
1021 }
1022
1023 interface LoDashStatic {
1024 /**
1025 * This method returns an empty string.
1026 *
1027 * @returns Returns the empty string.
1028 */
1029 stubString(): string;
1030 }
1031 interface LoDashImplicitWrapper<TValue> {
1032 /**
1033 * @see _.stubString
1034 */
1035 stubString(): string;
1036 }
1037 interface LoDashExplicitWrapper<TValue> {
1038 /**
1039 * @see _.stubString
1040 */
1041 stubString(): StringChain;
1042 }
1043
1044 interface LoDashStatic {
1045 /**
1046 * This method returns `true`.
1047 *
1048 * @returns Returns `true`.
1049 */
1050 stubTrue(): true;
1051 }
1052 interface LoDashImplicitWrapper<TValue> {
1053 /**
1054 * @see _.stubTrue
1055 */
1056 stubTrue(): true;
1057 }
1058 interface LoDashExplicitWrapper<TValue> {
1059 /**
1060 * @see _.stubTrue
1061 */
1062 stubTrue(): PrimitiveChain<true>;
1063 }
1064
1065 interface LoDashStatic {
1066 /**
1067 * Invokes the iteratee function n times, returning an array of the results of each invocation. The iteratee
1068 * is invoked with one argument; (index).
1069 *
1070 * @param n The number of times to invoke iteratee.
1071 * @param iteratee The function invoked per iteration.
1072 * @return Returns the array of results.
1073 */
1074 times<TResult>(n: number, iteratee: (num: number) => TResult): TResult[];
1075 /**
1076 * @see _.times
1077 */
1078 times(n: number): number[];
1079 }
1080 interface LoDashImplicitWrapper<TValue> {
1081 /**
1082 * @see _.times
1083 */
1084 times<TResult>(iteratee: (num: number) => TResult): TResult[];
1085 /**
1086 * @see _.times
1087 */
1088 times(): number[];
1089 }
1090 interface LoDashExplicitWrapper<TValue> {
1091 /**
1092 * @see _.times
1093 */
1094 times<TResult>(iteratee: (num: number) => TResult): CollectionChain<TResult>;
1095 /**
1096 * @see _.times
1097 */
1098 times(): CollectionChain<number>;
1099 }
1100
1101 interface LoDashStatic {
1102 /**
1103 * Converts `value` to a property path array.
1104 *
1105 * @category Util
1106 * @param value The value to convert.
1107 * @returns Returns the new property path array.
1108 * @example
1109 *
1110 * _.toPath('a.b.c');
1111 * // => ['a', 'b', 'c']
1112 *
1113 * _.toPath('a[0].b.c');
1114 * // => ['a', '0', 'b', 'c']
1115 *
1116 * var path = ['a', 'b', 'c'],
1117 * newPath = _.toPath(path);
1118 *
1119 * console.log(newPath);
1120 * // => ['a', 'b', 'c']
1121 *
1122 * console.log(path === newPath);
1123 * // => false
1124 */
1125 toPath(value: any): string[];
1126 }
1127 interface LoDashImplicitWrapper<TValue> {
1128 /**
1129 * @see _.toPath
1130 */
1131 toPath(): Collection<string>;
1132 }
1133 interface LoDashExplicitWrapper<TValue> {
1134 /**
1135 * @see _.toPath
1136 */
1137 toPath(): CollectionChain<string>;
1138 }
1139
1140 interface LoDashStatic {
1141 /**
1142 * Generates a unique ID. If prefix is provided the ID is appended to it.
1143 *
1144 * @param prefix The value to prefix the ID with.
1145 * @return Returns the unique ID.
1146 */
1147 uniqueId(prefix?: string): string;
1148 }
1149 interface LoDashImplicitWrapper<TValue> {
1150 /**
1151 * @see _.uniqueId
1152 */
1153 uniqueId(): string;
1154 }
1155 interface LoDashExplicitWrapper<TValue> {
1156 /**
1157 * @see _.uniqueId
1158 */
1159 uniqueId(): StringChain;
1160 }
1161}