Skip to content

Commit 7dd5b5f

Browse files
committed
Include dist files
1 parent 1b2c743 commit 7dd5b5f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+2732
-5
lines changed

.gitignore

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
node_modules
2-
.DS_Store
3-
coverage
4-
.rpt2_cache
5-
dist
1+
node_modules
2+
.DS_Store
3+
coverage
4+
.rpt2_cache

dist/Random.d.ts

Lines changed: 158 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,158 @@
1+
import { Engine } from "./types";
2+
/**
3+
* A wrapper around an Engine that provides easy-to-use methods for
4+
* producing values based on known distributions
5+
*/
6+
export declare class Random {
7+
private readonly engine;
8+
/**
9+
* Creates a new Random wrapper
10+
* @param engine The engine to use (defaults to a `Math.random`-based implementation)
11+
*/
12+
constructor();
13+
/**
14+
* Creates a new Random wrapper
15+
* @param engine The engine to use (explicitly provided)
16+
*/
17+
constructor(engine: Engine);
18+
/**
19+
* Creates a new Random wrapper that automatically detects
20+
* and uses the best available engine for the current environment.
21+
* @returns A Random instance using auto-detected engine
22+
*/
23+
static auto(): Random;
24+
/**
25+
* Returns a value within [-0x80000000, 0x7fffffff]
26+
*/
27+
int32(): number;
28+
/**
29+
* Returns a value within [0, 0xffffffff]
30+
*/
31+
uint32(): number;
32+
/**
33+
* Returns a value within [0, 0x1fffffffffffff]
34+
*/
35+
uint53(): number;
36+
/**
37+
* Returns a value within [0, 0x20000000000000]
38+
*/
39+
uint53Full(): number;
40+
/**
41+
* Returns a value within [-0x20000000000000, 0x1fffffffffffff]
42+
*/
43+
int53(): number;
44+
/**
45+
* Returns a value within [-0x20000000000000, 0x20000000000000]
46+
*/
47+
int53Full(): number;
48+
/**
49+
* Returns a value within [min, max]
50+
* @param minimum The minimum integer value, inclusive. No less than -0x20000000000000.
51+
* @param maximum The maximum integer value, inclusive. No greater than 0x20000000000000.
52+
*/
53+
integer(minimum: number, maximum: number): number;
54+
/**
55+
* Returns the maximum of the values specified within [min, max]
56+
* @param minimum The minimum integer value, inclusive. No less than -0x20000000000000. Discarded.
57+
* @param maximum The maximum integer value, inclusive. No greater than 0x20000000000000.
58+
*/
59+
max(minimum: number, maximum: number): number;
60+
/**
61+
* Returns the minimum of the values specified within [min, max]
62+
* @param minimum The minimum integer value, inclusive. No less than -0x20000000000000.
63+
* @param maximum The maximum integer value, inclusive. No greater than 0x20000000000000. Discarded.
64+
*/
65+
min(minimum: number, maximum: number): number;
66+
/**
67+
* Returns a floating-point value within [0.0, 1.0]
68+
*/
69+
realZeroToOneInclusive(): number;
70+
/**
71+
* Returns a floating-point value within [0.0, 1.0)
72+
*/
73+
realZeroToOneExclusive(): number;
74+
/**
75+
* Returns a floating-point value within [min, max) or [min, max]
76+
* @param min The minimum floating-point value, inclusive.
77+
* @param max The maximum floating-point value.
78+
* @param inclusive If true, `max` will be inclusive.
79+
*/
80+
real(minimum: number, maximum: number, inclusive?: boolean): number;
81+
/**
82+
* Returns a boolean with 50% probability of being true or false
83+
*/
84+
bool(): boolean;
85+
/**
86+
* Returns a boolean with the provided `percentage` of being true
87+
* @param percentage A number within [0, 1] of how often the result should be `true`
88+
*/
89+
bool(percentage: number): boolean;
90+
/**
91+
* Returns a boolean with a probability of `numerator`/`denominator` of being true
92+
* @param numerator The numerator of the probability
93+
* @param denominator The denominator of the probability
94+
*/
95+
bool(numerator: number, denominator: number): boolean;
96+
/**
97+
* Return a random value within the provided `source` within the sliced
98+
* bounds of `begin` and `end`.
99+
* @param source an array of items to pick from
100+
* @param begin the beginning slice index (defaults to `0`)
101+
* @param end the ending slice index (defaults to `source.length`)
102+
*/
103+
pick<T>(source: ArrayLike<T>, begin?: number, end?: number): T;
104+
/**
105+
* Shuffles an array in-place
106+
* @param array The array to shuffle
107+
*/
108+
shuffle<T>(array: T[]): T[];
109+
/**
110+
* From the population array, returns an array with sampleSize elements that
111+
* are randomly chosen without repeats.
112+
* @param population An array that has items to choose a sample from
113+
* @param sampleSize The size of the result array
114+
*/
115+
sample<T>(population: ArrayLike<T>, sampleSize: number): T[];
116+
/**
117+
* Returns a value within [1, sideCount]
118+
* @param sideCount The number of sides of the die
119+
*/
120+
die(sideCount: number): number;
121+
/**
122+
* Returns an array of length `dieCount` of values within [1, sideCount]
123+
* @param sideCount The number of sides of each die
124+
* @param dieCount The number of dice
125+
*/
126+
dice(sideCount: number, dieCount: number): number[];
127+
/**
128+
* Returns a Universally Unique Identifier Version 4.
129+
*
130+
* See https://en.wikipedia.org/wiki/Universally_unique_identifier
131+
*/
132+
uuid4(): string;
133+
/**
134+
* Returns a random string using numbers, uppercase and lowercase letters,
135+
* `_`, and `-` of length `length`.
136+
* @param length Length of the result string
137+
*/
138+
string(length: number): string;
139+
/**
140+
* Returns a random string using the provided string pool as the possible
141+
* characters to choose from of length `length`.
142+
* @param length Length of the result string
143+
*/
144+
string(length: number, pool: string): string;
145+
/**
146+
* Returns a random string comprised of numbers or the characters `abcdef`
147+
* (or `ABCDEF`) of length `length`.
148+
* @param length Length of the result string
149+
* @param uppercase Whether the string should use `ABCDEF` instead of `abcdef`
150+
*/
151+
hex(length: number, uppercase?: boolean): string;
152+
/**
153+
* Returns a random `Date` within the inclusive range of [`start`, `end`].
154+
* @param start The minimum `Date`
155+
* @param end The maximum `Date`
156+
*/
157+
date(start: Date, end: Date): Date;
158+
}

dist/distribution/bool.d.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { Distribution } from "../types";
2+
/**
3+
* Returns a boolean Distribution with 50% probability of being true or false
4+
*/
5+
export declare function bool(): Distribution<boolean>;
6+
/**
7+
* Returns a boolean Distribution with the provided `percentage` of being true
8+
* @param percentage A number within [0, 1] of how often the result should be `true`
9+
*/
10+
export declare function bool(percentage: number): Distribution<boolean>;
11+
/**
12+
* Returns a boolean Distribution with a probability of
13+
* `numerator` divided by `denominator` of being true
14+
* @param numerator The numerator of the probability
15+
* @param denominator The denominator of the probability
16+
*/
17+
export declare function bool(numerator: number, denominator: number): Distribution<boolean>;

dist/distribution/date.d.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { Distribution } from "../types";
2+
/**
3+
* Returns a Distribution that returns a random `Date` within the inclusive
4+
* range of [`start`, `end`].
5+
* @param start The minimum `Date`
6+
* @param end The maximum `Date`
7+
*/
8+
export declare function date(start: Date, end: Date): Distribution<Date>;

dist/distribution/dice.d.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { Distribution } from "../types";
2+
/**
3+
* Returns a distribution that returns an array of length `dieCount` of values
4+
* within [1, `sideCount`]
5+
* @param sideCount The number of sides of each die
6+
* @param dieCount The number of dice
7+
*/
8+
export declare function dice(sideCount: number, dieCount: number): Distribution<number[]>;

dist/distribution/die.d.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { Distribution } from "../types";
2+
/**
3+
* Returns a Distribution to return a value within [1, sideCount]
4+
* @param sideCount The number of sides of the die
5+
*/
6+
export declare function die(sideCount: number): Distribution<number>;

dist/distribution/hex.d.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { StringDistribution } from "../types";
2+
/**
3+
* Returns a Distribution that returns a random string comprised of numbers
4+
* or the characters `abcdef` (or `ABCDEF`) of length `length`.
5+
* @param length Length of the result string
6+
* @param uppercase Whether the string should use `ABCDEF` instead of `abcdef`
7+
*/
8+
export declare function hex(uppercase?: boolean): StringDistribution;

dist/distribution/int32.d.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { Engine } from "../types";
2+
/**
3+
* Returns a value within [-0x80000000, 0x7fffffff]
4+
*/
5+
export declare function int32(engine: Engine): number;

dist/distribution/int53.d.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { Engine } from "../types";
2+
/**
3+
* Returns a value within [-0x20000000000000, 0x1fffffffffffff]
4+
*/
5+
export declare function int53(engine: Engine): number;

dist/distribution/int53Full.d.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { Engine } from "../types";
2+
/**
3+
* Returns a value within [-0x20000000000000, 0x20000000000000]
4+
*/
5+
export declare function int53Full(engine: Engine): number;

0 commit comments

Comments
 (0)