UNPKG

11.6 kBTypeScriptView Raw
1import _ = require("../index");
2declare module "../index" {
3 interface LoDashStatic {
4 /**
5 * Adds two numbers.
6 *
7 * @param augend The first number to add.
8 * @param addend The second number to add.
9 * @return Returns the sum.
10 */
11 add(augend: number, addend: number): number;
12 }
13 interface LoDashImplicitWrapper<TValue> {
14 /**
15 * @see _.add
16 */
17 add(addend: number): number;
18 }
19 interface LoDashExplicitWrapper<TValue> {
20 /**
21 * @see _.add
22 */
23 add(addend: number): PrimitiveChain<number>;
24 }
25
26 interface LoDashStatic {
27 /**
28 * Calculates n rounded up to precision.
29 *
30 * @param n The number to round up.
31 * @param precision The precision to round up to.
32 * @return Returns the rounded up number.
33 */
34 ceil(n: number, precision?: number): number;
35 }
36 interface LoDashImplicitWrapper<TValue> {
37 /**
38 * @see _.ceil
39 */
40 ceil(precision?: number): number;
41 }
42 interface LoDashExplicitWrapper<TValue> {
43 /**
44 * @see _.ceil
45 */
46 ceil(precision?: number): PrimitiveChain<number>;
47 }
48
49 interface LoDashStatic {
50 /**
51 * Divide two numbers.
52 *
53 * @param dividend The first number in a division.
54 * @param divisor The second number in a division.
55 * @returns Returns the quotient.
56 */
57 divide(dividend: number, divisor: number): number;
58 }
59 interface LoDashImplicitWrapper<TValue> {
60 /**
61 * @see _.divide
62 */
63 divide(divisor: number): number;
64 }
65 interface LoDashExplicitWrapper<TValue> {
66 /**
67 * @see _.divide
68 */
69 divide(divisor: number): PrimitiveChain<number>;
70 }
71
72 interface LoDashStatic {
73 /**
74 * Calculates n rounded down to precision.
75 *
76 * @param n The number to round down.
77 * @param precision The precision to round down to.
78 * @return Returns the rounded down number.
79 */
80 floor(n: number, precision?: number): number;
81 }
82 interface LoDashImplicitWrapper<TValue> {
83 /**
84 * @see _.floor
85 */
86 floor(precision?: number): number;
87 }
88 interface LoDashExplicitWrapper<TValue> {
89 /**
90 * @see _.floor
91 */
92 floor(precision?: number): PrimitiveChain<number>;
93 }
94
95 interface LoDashStatic {
96 /**
97 * Computes the maximum value of `array`. If `array` is empty or falsey
98 * `undefined` is returned.
99 *
100 * @category Math
101 * @param array The array to iterate over.
102 * @returns Returns the maximum value.
103 */
104 max<T>(collection: List<T> | null | undefined): T | undefined;
105 }
106 interface Collection<T> {
107 /**
108 * @see _.max
109 */
110 max(): T | undefined;
111 }
112 interface CollectionChain<T> {
113 /**
114 * @see _.max
115 */
116 max(): ExpChain<T | undefined>;
117 }
118
119 interface LoDashStatic {
120 /**
121 * This method is like `_.max` except that it accepts `iteratee` which is
122 * invoked for each element in `array` to generate the criterion by which
123 * the value is ranked. The iteratee is invoked with one argument: (value).
124 *
125 * @category Math
126 * @param array The array to iterate over.
127 * @param iteratee The iteratee invoked per element.
128 * @returns Returns the maximum value.
129 * @example
130 *
131 * var objects = [{ 'n': 1 }, { 'n': 2 }];
132 *
133 * _.maxBy(objects, function(o) { return o.n; });
134 * // => { 'n': 2 }
135 *
136 * // using the `_.property` iteratee shorthand
137 * _.maxBy(objects, 'n');
138 * // => { 'n': 2 }
139 */
140 maxBy<T>(collection: List<T> | null | undefined, iteratee?: ValueIteratee<T>): T | undefined;
141 }
142 interface Collection<T> {
143 /**
144 * @see _.maxBy
145 */
146 maxBy(iteratee?: ValueIteratee<T>): T | undefined;
147 }
148 interface CollectionChain<T> {
149 /**
150 * @see _.maxBy
151 */
152 maxBy(iteratee?: ValueIteratee<T>): ExpChain<T | undefined>;
153 }
154
155 interface LoDashStatic {
156 /**
157 * Computes the mean of the values in `array`.
158 *
159 * @category Math
160 * @param array The array to iterate over.
161 * @returns Returns the mean.
162 * @example
163 *
164 * _.mean([4, 2, 8, 6]);
165 * // => 5
166 */
167 mean(collection: List<any> | null | undefined): number;
168 }
169 interface LoDashImplicitWrapper<TValue> {
170 /**
171 * @see _.mean
172 */
173 mean(): number;
174 }
175 interface LoDashExplicitWrapper<TValue> {
176 /**
177 * @see _.mean
178 */
179 mean(): PrimitiveChain<number>;
180 }
181
182 interface LoDashStatic {
183 /**
184 * Computes the mean of the provided properties of the objects in the `array`
185 *
186 * @category Math
187 * @param array The array to iterate over.
188 * @param iteratee The iteratee invoked per element.
189 * @returns Returns the mean.
190 * @example
191 *
192 * _.mean([{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }], 'n');
193 * // => 5
194 */
195 meanBy<T>(collection: List<T> | null | undefined, iteratee?: ValueIteratee<T>): number;
196 }
197 interface Collection<T> {
198 /**
199 * @see _.meanBy
200 */
201 meanBy(iteratee?: ValueIteratee<T>): number;
202 }
203 interface CollectionChain<T> {
204 /**
205 * @see _.meanBy
206 */
207 meanBy(iteratee?: ValueIteratee<T>): PrimitiveChain<number>;
208 }
209
210 interface LoDashStatic {
211 /**
212 * Computes the minimum value of `array`. If `array` is empty or falsey
213 * `undefined` is returned.
214 *
215 * @category Math
216 * @param array The array to iterate over.
217 * @returns Returns the minimum value.
218 */
219 min<T>(collection: List<T> | null | undefined): T | undefined;
220 }
221 interface Collection<T> {
222 /**
223 * @see _.min
224 */
225 min(): T | undefined;
226 }
227 interface CollectionChain<T> {
228 /**
229 * @see _.min
230 */
231 min(): ExpChain<T | undefined>;
232 }
233
234 interface LoDashStatic {
235 /**
236 * This method is like `_.min` except that it accepts `iteratee` which is
237 * invoked for each element in `array` to generate the criterion by which
238 * the value is ranked. The iteratee is invoked with one argument: (value).
239 *
240 * @category Math
241 * @param array The array to iterate over.
242 * @param iteratee The iteratee invoked per element.
243 * @returns Returns the minimum value.
244 * @example
245 *
246 * var objects = [{ 'n': 1 }, { 'n': 2 }];
247 *
248 * _.minBy(objects, function(o) { return o.a; });
249 * // => { 'n': 1 }
250 *
251 * // using the `_.property` iteratee shorthand
252 * _.minBy(objects, 'n');
253 * // => { 'n': 1 }
254 */
255 minBy<T>(collection: List<T> | null | undefined, iteratee?: ValueIteratee<T>): T | undefined;
256 }
257 interface Collection<T> {
258 /**
259 * @see _.minBy
260 */
261 minBy(iteratee?: ValueIteratee<T>): T | undefined;
262 }
263 interface CollectionChain<T> {
264 /**
265 * @see _.minBy
266 */
267 minBy(iteratee?: ValueIteratee<T>): ExpChain<T | undefined>;
268 }
269
270 interface LoDashStatic {
271 /**
272 * Multiply two numbers.
273 * @param multiplier The first number in a multiplication.
274 * @param multiplicand The second number in a multiplication.
275 * @returns Returns the product.
276 */
277 multiply(multiplier: number, multiplicand: number): number;
278 }
279 interface LoDashImplicitWrapper<TValue> {
280 /**
281 * @see _.multiply
282 */
283 multiply(multiplicand: number): number;
284 }
285 interface LoDashExplicitWrapper<TValue> {
286 /**
287 * @see _.multiply
288 */
289 multiply(multiplicand: number): PrimitiveChain<number>;
290 }
291
292 interface LoDashStatic {
293 /**
294 * Calculates n rounded to precision.
295 *
296 * @param n The number to round.
297 * @param precision The precision to round to.
298 * @return Returns the rounded number.
299 */
300 round(n: number, precision?: number): number;
301 }
302 interface LoDashImplicitWrapper<TValue> {
303 /**
304 * @see _.round
305 */
306 round(precision?: number): number;
307 }
308 interface LoDashExplicitWrapper<TValue> {
309 /**
310 * @see _.round
311 */
312 round(precision?: number): PrimitiveChain<number>;
313 }
314
315 interface LoDashStatic {
316 /**
317 * Subtract two numbers.
318 *
319 * @category Math
320 * @param minuend The first number in a subtraction.
321 * @param subtrahend The second number in a subtraction.
322 * @returns Returns the difference.
323 * @example
324 *
325 * _.subtract(6, 4);
326 * // => 2
327 */
328 subtract(minuend: number, subtrahend: number): number;
329 }
330 interface LoDashImplicitWrapper<TValue> {
331 /**
332 * @see _.subtract
333 */
334 subtract(subtrahend: number): number;
335 }
336 interface LoDashExplicitWrapper<TValue> {
337 /**
338 * @see _.subtract
339 */
340 subtract(subtrahend: number): PrimitiveChain<number>;
341 }
342
343 interface LoDashStatic {
344 /**
345 * Computes the sum of the values in `array`.
346 *
347 * @category Math
348 * @param array The array to iterate over.
349 * @returns Returns the sum.
350 * @example
351 *
352 * _.sum([4, 2, 8, 6]);
353 * // => 20
354 */
355 sum(collection: List<any> | null | undefined): number;
356 }
357 interface LoDashImplicitWrapper<TValue> {
358 /**
359 * @see _.sum
360 */
361 sum(): number;
362 }
363 interface LoDashExplicitWrapper<TValue> {
364 /**
365 * @see _.sum
366 */
367 sum(): PrimitiveChain<number>;
368 }
369
370 interface LoDashStatic {
371 /**
372 * This method is like `_.sum` except that it accepts `iteratee` which is
373 * invoked for each element in `array` to generate the value to be summed.
374 * The iteratee is invoked with one argument: (value).
375 *
376 * @category Math
377 * @param array The array to iterate over.
378 * @param [iteratee=_.identity] The iteratee invoked per element.
379 * @returns Returns the sum.
380 * @example
381 *
382 * var objects = [{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }];
383 *
384 * _.sumBy(objects, function(o) { return o.n; });
385 * // => 20
386 *
387 * // using the `_.property` iteratee shorthand
388 * _.sumBy(objects, 'n');
389 * // => 20
390 */
391 sumBy<T>(collection: List<T> | null | undefined, iteratee?: ((value: T) => number) | string): number;
392 }
393 interface Collection<T> {
394 /**
395 * @see _.sumBy
396 */
397 sumBy(iteratee?: ((value: T) => number) | string): number;
398 }
399 interface CollectionChain<T> {
400 /**
401 * @see _.sumBy
402 */
403 sumBy(iteratee?: ((value: T) => number) | string): PrimitiveChain<number>;
404 }
405}
406
\No newline at end of file