diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index 903a0e7b9..0f789370a 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -2505,6 +2505,24 @@ result = _.inRange(4, 8); result = _(3).inRange(2, 4); result = _(4).inRange(8); +// _.random +module TestRandom { + let result: number; + + result = _.random(); + result = _.random(1); + result = _.random(1, 2); + result = _.random(1, 2, true); + result = _.random(1, true); + result = _.random(true); + + result = _(1).random(); + result = _(1).random(2); + result = _(1).random(2, true); + result = _(1).random(true); + result = _(true).random(); +} + /********* * Object * **********/ @@ -2982,12 +3000,6 @@ var testAttempFn: TestAttemptFn; result = _.attempt(testAttempFn); result = _(testAttempFn).attempt(); -result = _.random(0, 5); -result = _.random(5); -result = _.random(5, true); -result = _.random(1.2, 5.2); -result = _.random(0, 5, true); - // _.noop result = _.noop(); result = _.noop(1); diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index 1f07bd1e4..69e240748 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -7356,6 +7356,53 @@ declare module _ { inRange(end: number): boolean; } + //_.random + interface LoDashStatic { + /** + * Produces a random number between min and max (inclusive). If only one argument is provided a number between + * 0 and the given number is returned. If floating is true, or either min or max are floats, a floating-point + * number is returned instead of an integer. + * + * @param min The minimum possible value. + * @param max The maximum possible value. + * @param floating Specify returning a floating-point number. + * @return Returns the random number. + */ + random( + min?: number, + max?: number, + floating?: boolean + ): number; + + /** + * @see _.random + */ + random( + min?: number, + floating?: boolean + ): number; + + /** + * @see _.random + */ + random(floating?: boolean): number; + } + + interface LoDashWrapper { + /** + * @see _.random + */ + random( + max?: number, + floating?: boolean + ): number; + + /** + * @see _.random + */ + random(floating?: boolean): number; + } + /********** * Object * **********/ @@ -9528,26 +9575,6 @@ declare module _ { step?: number): LoDashArrayWrapper; } - //_.random - interface LoDashStatic { - /** - * Produces a random number between min and max (inclusive). If only one argument is provided a - * number between 0 and the given number will be returned. If floating is truey or either min or - * max are floats a floating-point number will be returned instead of an integer. - * @param max The maximum possible value. - * @param floating Specify returning a floating-point number. - * @return A random number. - **/ - random(max: number, floating?: boolean): number; - - /** - * @see _.random - * @param min The minimum possible value. - * @return A random number between `min` and `max`. - **/ - random(min: number, max: number, floating?: boolean): number; - } - //_.runInContext interface LoDashStatic { /**