From b39cce34194829c74791c7e9a4dd4313f73fd62a Mon Sep 17 00:00:00 2001 From: Ilya Mochalov Date: Wed, 14 Oct 2015 03:25:54 +0500 Subject: [PATCH] lodash: signatures of the method _.random have been changed --- lodash/lodash-tests.ts | 24 +++++++++++---- lodash/lodash.d.ts | 67 +++++++++++++++++++++++++++++------------- 2 files changed, 65 insertions(+), 26 deletions(-) diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index 7dd2249c9..e96e02ebb 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -2434,6 +2434,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 * **********/ @@ -2911,12 +2929,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 60aaf60b7..9faa72f1b 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -7243,6 +7243,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 * **********/ @@ -9415,26 +9462,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 { /**