UNPKG

4.02 kBTypeScriptView Raw
1import _ = require("../index");
2declare module "../index" {
3 // clamp
4 interface LoDashStatic {
5 /**
6 * Clamps `number` within the inclusive `lower` and `upper` bounds.
7 *
8 * @category Number
9 * @param number The number to clamp.
10 * @param [lower] The lower bound.
11 * @param upper The upper bound.
12 * @returns Returns the clamped number.
13 * @example
14 *
15 * _.clamp(-10, -5, 5);
16 * // => -5
17 *
18 * _.clamp(10, -5, 5);
19 * // => 5
20 * Clamps `number` within the inclusive `lower` and `upper` bounds.
21 *
22 * @category Number
23 * @param number The number to clamp.
24 * @param [lower] The lower bound.
25 * @param upper The upper bound.
26 * @returns Returns the clamped number.
27 * @example
28 *
29 * _.clamp(-10, -5, 5);
30 * // => -5
31 *
32 * _.clamp(10, -5, 5);
33 */
34 clamp(number: number, lower: number, upper: number): number;
35 /**
36 * @see _.clamp
37 */
38 clamp(number: number, upper: number): number;
39 }
40 interface LoDashImplicitWrapper<TValue> {
41 /**
42 * @see _.clamp
43 */
44 clamp(lower: number, upper: number): number;
45 /**
46 * @see _.clamp
47 */
48 clamp(upper: number): number;
49 }
50 interface LoDashExplicitWrapper<TValue> {
51 /**
52 * @see _.clamp
53 */
54 clamp(lower: number, upper: number): PrimitiveChain<number>;
55 /**
56 * @see _.clamp
57 */
58 clamp(upper: number): PrimitiveChain<number>;
59 }
60 // inRange
61 interface LoDashStatic {
62 /**
63 * Checks if n is between start and up to but not including, end. If end is not specified it’s set to start
64 * with start then set to 0.
65 *
66 * @param n The number to check.
67 * @param start The start of the range.
68 * @param end The end of the range.
69 * @return Returns true if n is in the range, else false.
70 */
71 inRange(n: number, start: number, end?: number): boolean;
72 }
73 interface LoDashImplicitWrapper<TValue> {
74 /**
75 * @see _.inRange
76 */
77 inRange(start: number, end?: number): boolean;
78 }
79 interface LoDashExplicitWrapper<TValue> {
80 /**
81 * @see _.inRange
82 */
83 inRange(start: number, end?: number): PrimitiveChain<boolean>;
84 }
85 // random
86 interface LoDashStatic {
87 /**
88 * Produces a random number between min and max (inclusive). If only one argument is provided a number between
89 * 0 and the given number is returned. If floating is true, or either min or max are floats, a floating-point
90 * number is returned instead of an integer.
91 *
92 * @param min The minimum possible value.
93 * @param max The maximum possible value.
94 * @param floating Specify returning a floating-point number.
95 * @return Returns the random number.
96 */
97 random(floating?: boolean): number;
98 /**
99 * @see _.random
100 */
101 random(max: number, floating?: boolean): number;
102 /**
103 * @see _.random
104 */
105 random(min: number, max: number, floating?: boolean): number;
106 /**
107 * @see _.random
108 */
109 random(min: number, index: string | number, guard: object): number;
110 }
111 interface LoDashImplicitWrapper<TValue> {
112 /**
113 * @see _.random
114 */
115 random(floating?: boolean): number;
116 /**
117 * @see _.random
118 */
119 random(max: number, floating?: boolean): number;
120 }
121 interface LoDashExplicitWrapper<TValue> {
122 /**
123 * @see _.random
124 */
125 random(floating?: boolean): PrimitiveChain<number>;
126 /**
127 * @see _.random
128 */
129 random(max: number, floating?: boolean): PrimitiveChain<number>;
130 }
131}