UNPKG

1.16 kBTypeScriptView Raw
1/** @module random */
2/**
3 * Random generator for float values.
4 *
5 * ### Example ###
6 *
7 * let value1 = RandomFloat.nextFloat(5, 10); // Possible result: 7.3
8 * let value2 = RandomFloat.nextFloat(10); // Possible result: 3.7
9 * let value3 = RandomFloat.updateFloat(10, 3); // Possible result: 9.2
10 */
11export declare class RandomFloat {
12 /**
13 * Generates a float in the range ['min', 'max']. If 'max' is omitted, then the range will be set to [0, 'min'].
14 *
15 * @param min minimum value of the float that will be generated.
16 * If 'max' is omitted, then 'max' is set to 'min' and 'min' is set to 0.
17 * @param max (optional) maximum value of the float that will be generated. Defaults to 'min' if omitted.
18 * @returns generated random float value.
19 */
20 static nextFloat(min: number, max?: number): number;
21 /**
22 * Updates (drifts) a float value within specified range defined
23 *
24 * @param value a float value to drift.
25 * @param range (optional) a range. Default: 10% of the value
26 */
27 static updateFloat(value: number, range?: number): number;
28}