diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index 4578b1a5c..4f5aa03e9 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -726,6 +726,12 @@ var lodash = _.noConflict(); result = _.parseInt('08'); +result = _.random(0, 5); +result = _.random(5); +result = _.random(5, true); +result = _.random(1.2, 5.2); +result = _.random(0, 5, true); + ////////////////////////////////////////////////////////////////////////////////////////////////// var iceCream = { flavor: "chocolate" }; diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index 68c4ff5e8..0739e996b 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -2745,7 +2745,22 @@ declare module _ { **/ export function parseInt(value: string): number; + /** + * 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. + **/ + export function random(max: number, floating?: boolean): number; + /** + * @see _.random + * @param min The minimum possible value. + * @return A random number between `min` and `max`. + **/ + export function random(min: number, max: number, floating?: boolean): number; @@ -2765,23 +2780,6 @@ declare module _ { **/ export function times(n: number, iterator: (n: number) => TResult, context?: any): TResult[]; - /** - * Returns a random integer between min and max, inclusive. If you only pass one argument, - * it will return a number between 0 and that number. - * @param max The maximum random number. - * @return A random number between 0 and `max`. - **/ - export function random(max: number): number; - - /** - * @see _.random - * @param min The minimum random number. - * @return A random number between `min` and `max`. - **/ - export function random(min: number, max: number): number; - - - /** * Generate a globally-unique id for client-side models or DOM elements that need one. * If prefix is passed, the id will be appended to it. Without prefix, returns an integer.