-
-
Notifications
You must be signed in to change notification settings - Fork 7
/
index.d.ts
69 lines (53 loc) · 1.65 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
import Color from 'color';
export interface Options {
/**
[Initialization seed.](https://en.wikipedia.org/wiki/Random_seed)
Multiple instances of `Randoma` with the same seed will generate the same random numbers.
*/
readonly seed: string | number;
}
export default class Randoma {
/**
@returns A random seed you could use in the `seed` option if you for some reason don't want deterministic randomness.
*/
static seed(): number;
/**
User-friendly [pseudorandom number generator (PRNG)](https://en.wikipedia.org/wiki/Pseudorandom_number_generator).
This is not cryptographically secure.
@example
```
import Randoma from 'randoma';
const random = new Randoma({seed: 10});
random.integer();
//=> 2027521326
random.integer();
//=> 677268843
(new Randoma({seed: '🦄'}).integer());
//=> 1659974344
(new Randoma({seed: '🦄'}).integer());
//=> 1659974344
```
*/
constructor(options: Options);
integer(): number;
integerInRange(minimum: number, maximum: number): number;
float(): number;
floatInRange(minimum: number, maximum: number): number;
boolean(): boolean;
arrayItem<T>(array: readonly T[]): T;
date(): Date;
dateInRange(startDate: Date, endDate: Date): Date;
/**
@param saturation - A percentage in the range `0...1`. Default: `0.5`.
@returns A random [aesthetically pleasing color](https://martin.ankerl.com/2009/12/09/how-to-create-random-colors-programmatically/) as a [`color`](https://github.com/Qix-/color) object.
@example
```
random.color(0.5).hex().toString()
//=> '#AAF2B0'
```
*/
color(saturation?: number): Color;
}
export {Color};
// TODO: When `color` package is ESM.
// export {default as Color} from 'color';