toosoon-prng 4.0.3 → 4.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,6 +1,8 @@
1
1
  # TOOSOON Pseudo-Random Number Generator (PRNG)
2
2
 
3
- This project provides PRNG functions for generating pseudo-random values using a seed-based approach and various algorithms. These are particularly useful for applications requiring deterministic randomization, such as procedural generation or simulations.
3
+ This project provides PRNG functions for generating pseudo-random values using a seed-based approach. These are particularly useful for applications requiring deterministic randomization, such as procedural generation or simulations.
4
+
5
+ [![NPM](https://nodei.co/npm/toosoon-prng.png)](https://nodei.co/npm/toosoon-prng/)
4
6
 
5
7
  ## Installation
6
8
 
@@ -18,172 +20,237 @@ $ npm install toosoon-prng
18
20
 
19
21
  ## Usage
20
22
 
23
+ Using default PRNG instance.
24
+
21
25
  ```ts
22
26
  import prng from 'toosoon-prng';
23
27
 
24
28
  prng.setSeed('seed');
25
- console.log(prng.randomFloat('angle', 0, Math.PI)); // Pseudo-random number in the interval [0, PI]
26
- ```
27
29
 
28
- ## PRNG Functions
30
+ prng.randomFloat('angle', 0, Math.PI); // Pseudo-random number in the interval [0, PI)
31
+ ```
29
32
 
30
- All PRNG functions have a `seed` parameter wich allows you to add a sub-seed string to the `PRNG` instance global `seed` in order to get different pseudo-random values while using a PRNG function multiple times.
33
+ Using PRNG class constructor.
31
34
 
32
35
  ```ts
33
- prng.setSeed('global-seed');
34
- console.log(prng.randomBoolean('one')); // Could be true or false
35
- console.log(prng.randomBoolean('two')); // Could be different from the first pseudo-random value
36
+ import { PRNG } from 'toosoon-prng';
37
+
38
+ const prng = new PRNG('seed');
39
+
40
+ prng.randomFloat('angle', 0, Math.PI); // Pseudo-random number in the interval [0, PI)
36
41
  ```
37
42
 
38
- ##### setSeed(seed)
43
+ ## API
39
44
 
40
- Set the `PRNG` instance seed.
45
+ ### PRNG <a id="prng"></a>
41
46
 
42
- - `seed`
47
+ Utility class for generating pseudo-random values.
48
+
49
+ - [new PRNG(seed?, generator?)](#prng-constructor)
50
+ - [.seed](#prng-seed): `string`
51
+ - [.generator](#prng-generator): `Function`
52
+ - [.setSeed(seed?)](#prng-set-seed-method): `void`
53
+ - [.random(subseed)](#prng-random-method): `number`
54
+ - [.randomBoolean(subseed, probability?)](#prng-random-boolean-method): `boolean`
55
+ - [.randomSign(subseed, probability?)](#prng-random-sign-method): `number`
56
+ - [.randomFloat(subseed, min?, max?, precision?)](#prng-random-float-method): `number`
57
+ - [.randomInt(subseed, min, max)](#prng-random-int-method): `number`
58
+ - [.randomHexColor(subseed)](#prng-random-hex-color-method): `string`
59
+ - [.randomItem(subseed, array)](#prng-random-item-method): `unknown|undefined`
60
+ - [.randomObjectProperty(subseed, object)](#prng-random-object-property-method): `unknown|undefined`
61
+ - [.randomIndex(subseed, weights)](#prng-random-index-method): `number`
62
+ - [.randomGaussian(subseed, mean?, spread?)](#prng-random-gaussian-method): `number`
63
+
64
+ #### Types
43
65
 
44
66
  ```ts
45
- prng.setSeed(seed: string | number): void;
67
+ type Seed = string | number;
68
+
69
+ type Generator = (...hashes: number[]) => number;
46
70
  ```
47
71
 
48
- ##### setAlgorithm(algorithmName)
72
+ #### Constructor <a id="prng-constructor"></a>
73
+
74
+ | Parameter | Type | Default | Description |
75
+ | ----------- | ----------- | ------- | ------------------------------------------------------ |
76
+ | [seed] | `Seed` | | Seed string used for pseudo-random generations. |
77
+ | [generator] | `Generator` | `sfc32` | Generator function used for pseudo-random generations. |
49
78
 
50
- Set the `PRNG` algorithm for generating pseudo-random values.
79
+ #### Properties
51
80
 
52
- - `algorithmName`: Algorithm name.
81
+ ##### .`seed` <a id="prng-seed"></a>
82
+
83
+ Seed string used for pseudo-random generations.
84
+
85
+ ```ts
86
+ PRNG.seed: string;
87
+ ```
88
+
89
+ ##### .`generator` <a id="prng-generator"></a>
90
+
91
+ Generator function used for pseudo-random generations.
53
92
 
54
93
  ```ts
55
- prng.setAlgorithm(algorithmName: AlgorithmName): void;
94
+ PRNG.generator: Generator;
56
95
  ```
57
96
 
58
- ##### random(seed)
97
+ #### Methods
59
98
 
60
- Generate a pseudo-random number in the interval [0, 1]. PRNG equivalent of `Math.random()`.
99
+ ##### .`setSeed(seed)` <a id="prng-set-seed-method"></a>
100
+
101
+ Set the `PRNG` instance seed.
61
102
 
62
103
  - `seed`
63
104
 
64
105
  ```ts
65
- prng.random(seed: string | number): number;
106
+ PRNG.setSeed(seed: Seed): void;
66
107
  ```
67
108
 
68
- ##### randomBoolean(seed)
109
+ ##### .`random(subseed)` <a id="prng-random-method"></a>
110
+
111
+ Generate a pseudo-random number between 0 and 1 (0 inclusive, 1 exclusive).
112
+ Pseudo-random equivalent of `Math.random()`.
113
+
114
+ - `subseed`
115
+
116
+ ```ts
117
+ PRNG.random(subseed: Seed): number;
118
+ ```
119
+
120
+ ##### .`randomBoolean(subseed, probability?)` <a id="prng-random-boolean-method"></a>
69
121
 
70
122
  Generate a pseudo-random boolean (true or false).
71
123
 
72
- - `seed`
124
+ - `subseed`
73
125
  - `[probability=0.5]`: Probability to get true.
74
126
 
75
127
  ```ts
76
- prng.randomBoolean(seed: string | number, probability?: number): boolean;
128
+ PRNG.randomBoolean(subseed: Seed, probability?: number): boolean;
77
129
  ```
78
130
 
79
- ##### randomSign(seed)
131
+ ##### .`randomSign(subseed, probability?)` <a id="prng-random-sign-method"></a>
80
132
 
81
133
  Generate a pseudo-random sign (1 or -1).
82
134
 
83
- - `seed`
135
+ - `subseed`
84
136
  - `[probability=0.5]`: Probability to get 1.
85
137
 
86
138
  ```ts
87
- prng.randomSign(seed: string | number, probability?: number): number;
139
+ PRNG.randomSign(subseed: Seed, probability?: number): number;
88
140
  ```
89
141
 
90
- ##### randomFloat(seed, min, max)
142
+ ##### .`randomFloat(subseed, min?, max?, precision?)` <a id="prng-random-float-method"></a>
91
143
 
92
- Generate pseudo-random a floating-point number within a specified range.
144
+ Generate a pseudo-random floating-point number within a specified range.
93
145
 
94
- - `seed`
146
+ - `subseed`
95
147
  - `[min=0]`: Minimum boundary.
96
148
  - `[max=1]`: Maximum boundary.
97
149
  - `[precison=2]`: Number of digits after the decimal point.
98
150
 
99
151
  ```ts
100
- prng.randomFloat(seed: string | number, min?: number, max?: number1, precision?: number): number;
152
+ PRNG.randomFloat(subseed: Seed, min?: number, max?: number1, precision?: number): number;
101
153
  ```
102
154
 
103
- ##### randomInt(seed, min, max)
155
+ ##### .`randomInt(subseed, min, max)` <a id="prng-random-int-method"></a>
104
156
 
105
- Generate pseudo-random integer number within a specified range.
157
+ Generate a pseudo-random integer number within a specified range.
106
158
 
107
- - `seed`
159
+ - `subseed`
108
160
  - `min`: Minimum boundary.
109
161
  - `max`: Maximum boundary.
110
162
 
111
163
  ```ts
112
- prng.randomInt(seed: string | number, min: number, max: number): void;
164
+ PRNG.randomInt(subseed: Seed, min: number, max: number): void;
113
165
  ```
114
166
 
115
- ##### randomHexColor(seed)
167
+ ##### .`randomHexColor(subseed)` <a id="prng-random-hex-color-method"></a>
116
168
 
117
169
  Generate a pseudo-random hexadecimal color.
118
170
 
119
- - `seed`
171
+ - `subseed`
120
172
 
121
173
  ```ts
122
- prng.randomHexColor(seed: string | number): string;
174
+ PRNG.randomHexColor(subseed: Seed): string;
123
175
  ```
124
176
 
125
- ##### randomItem(seed0 array)
177
+ ##### .`randomItem(subseed, array)` <a id="prng-random-item-method"></a>
126
178
 
127
- Pick a pseudo-random item from a given array.
179
+ Pseudo-randomly pick an item from an array.
128
180
 
129
- - `seed`
181
+ - `subseed`
130
182
  - `array`: Array to pick the item from.
131
183
 
132
184
  ```ts
133
- prng.randomItem<T>(seed: string | number, array: T[]): T | undefined;
185
+ PRNG.randomItem<T>(subseed: Seed, array: T[]): T | undefined;
134
186
  ```
135
187
 
136
- ##### randomObjectProperty(seed, object)
188
+ ##### .`randomObjectProperty(subseed, object)` <a id="prng-random-object-property-method"></a>
137
189
 
138
- Pick a pseudo-random property value from a given object.
190
+ Pseudo-randomly pick a property value from an object.
139
191
 
140
- - `seed`
192
+ - `subseed`
141
193
  - `object`: Object to pick the property from.
142
194
 
143
195
  ```ts
144
- prng.randomObjectProperty<T>(seed: string | number, object: Record<string, T>): T | undefined;
196
+ PRNG.randomObjectProperty<T>(subseed: Seed, object: Record<string, T>): T | undefined;
145
197
  ```
146
198
 
147
- ##### randomIndex(seed, weights)
199
+ ##### .`randomIndex(subseed, weights)` <a id="prng-random-index-method"></a>
148
200
 
149
201
  Select a pseudo-random index from an array of weighted items.
150
202
 
151
- - `seed`
152
- - `weights`: Array of weights
203
+ - `subseed`
204
+ - `weights`: Array of weights.
153
205
 
154
206
  ```ts
155
- prng.randomIndex(seed: string | number, weights: number[]): number;
207
+ PRNG.randomIndex(subseed: Seed, weights: number[]): number;
156
208
  ```
157
209
 
158
- ##### randomGaussian(seed, mean, spread)
210
+ ##### .`randomGaussian(subseed, mean?, spread?)` <a id="prng-random-gaussian-method"></a>
159
211
 
160
212
  Generate a pseudo-random number fitting a Gaussian (normal) distribution.
161
213
 
162
- `seed`
163
- `[mean=0]`: Central value.
164
- `[spread=1]`: Standard deviation.
214
+ - `subseed`
215
+ - `[mean=0]`: Mean (central) value of the distribution.
216
+ - `[spread=1]`: Spread (standard deviation) of the distribution.
165
217
 
166
218
  ```ts
167
- prng.randomGaussian(seed: string | number, mean?: number, spread?: number): number;
219
+ PRNG.randomGaussian(subseed: Seed, mean?: number, spread?: number): number;
168
220
  ```
169
221
 
170
- ## Algorithms
222
+ ### Generators
171
223
 
172
- By default, the library is using _SplitMix32_ algorithm for generating the pseudo-random values but it is possible to change the algorithm used by one of the following:
224
+ By default, the library is using _SplitMix32_ generator for generating the pseudo-random values but it is possible to change the generator used by one of the following:
173
225
 
174
- - `jsf32`: _Jenkins' Small Fast_, Generator with a 32-bit state.
175
- - `mulberry32`: _Mulberry32_, Generator with a 32-bit state.
176
226
  - `sfc32`: _Simple Fast Counter_, Generator with a 128-bit state.
177
- - `splitmix32`: _SplitMix32_, Generator with a 32-bit state.
227
+ - `jsf32`: _Jenkins' Small Fast_, Generator with a 128-bit state.
178
228
  - `xoshiro128ss`: _xoshiro128\*\*_, Generator with a 128-bit state.
229
+ - `mulberry32`: _Mulberry32_, Generator with a 32-bit state.
230
+ - `splitmix32`: _SplitMix32_, Generator with a 32-bit state.
179
231
 
180
232
  ```ts
181
- import prng, { Algorithm } from 'toosoon-prng';
233
+ import { PRNG, sfc32 } from 'toosoon-prng';
182
234
 
183
- // Set 'Simple Fast Counter' as the PRNG instance algorithm
184
- prng.setAlgorithm(Algorithm.sfc32);
235
+ const prng = new PRNG('seed', { generator: sfc32 });
185
236
  ```
186
237
 
238
+ ### Utils
239
+
240
+ ##### `randomSeed(length?)`
241
+
242
+ Generate a random string that can be used as a seed.
243
+
244
+ - `[length=64]`: Length of the generated seed string.
245
+
246
+ ```ts
247
+ randomSeed(length?: number): string;
248
+ ```
249
+
250
+ ### Constants
251
+
252
+ `DEFAULT_SEED`
253
+
187
254
  ## License
188
255
 
189
256
  MIT License, see [LICENSE](https://github.com/toosoon-dev/toosoon-prng/tree/master/LICENSE) for details.
@@ -0,0 +1 @@
1
+ export declare const DEFAULT_SEED = "0x0000000000000000000000000000000000000000000000000000000000000000";
@@ -0,0 +1 @@
1
+ export const DEFAULT_SEED = '0x0000000000000000000000000000000000000000000000000000000000000000';
@@ -0,0 +1,56 @@
1
+ /**
2
+ * Produce a 128-bit hash value from a seed string
3
+ *
4
+ * @param {string} seed
5
+ * @returns {[number, number, number, number]}
6
+ */
7
+ export declare function cyrb128(seed: string): [number, number, number, number];
8
+ /**
9
+ * Simple Fast Counter
10
+ * 128-bit state PRNG
11
+ *
12
+ * @param {number} a
13
+ * @param {number} b
14
+ * @param {number} c
15
+ * @param {number} d
16
+ * @returns {number}
17
+ */
18
+ export declare function sfc32(a: number, b: number, c: number, d: number): number;
19
+ /**
20
+ * Jenkins' Small Fast
21
+ * 128-bit state PRNG
22
+ *
23
+ * @param {number} a
24
+ * @param {number} b
25
+ * @param {number} c
26
+ * @param {number} d
27
+ * @returns {number}
28
+ */
29
+ export declare function jsf32(a: number, b: number, c: number, d: number): number;
30
+ /**
31
+ * xoshiro128**
32
+ * 128-bit state PRNG
33
+ *
34
+ * @param {number} a
35
+ * @param {number} b
36
+ * @param {number} c
37
+ * @param {number} d
38
+ * @returns {number}
39
+ */
40
+ export declare function xoshiro128ss(a: number, b: number, c: number, d: number): number;
41
+ /**
42
+ * Mulberry32
43
+ * 32-bit state PRNG
44
+ *
45
+ * @param {number} a
46
+ * @returns {number}
47
+ */
48
+ export declare function mulberry32(a: number): number;
49
+ /**
50
+ * SplitMix
51
+ * 32-bit state PRNG
52
+ *
53
+ * @param {number} a
54
+ * @returns {number}
55
+ */
56
+ export declare function splitmix32(a: number): number;
@@ -0,0 +1,125 @@
1
+ /**
2
+ * Produce a 128-bit hash value from a seed string
3
+ *
4
+ * @param {string} seed
5
+ * @returns {[number, number, number, number]}
6
+ */
7
+ export function cyrb128(seed) {
8
+ let h1 = 1779033703;
9
+ let h2 = 3144134277;
10
+ let h3 = 1013904242;
11
+ let h4 = 2773480762;
12
+ for (let i = 0, k; i < seed.length; i++) {
13
+ k = seed.charCodeAt(i);
14
+ h1 = h2 ^ Math.imul(h1 ^ k, 597399067);
15
+ h2 = h3 ^ Math.imul(h2 ^ k, 2869860233);
16
+ h3 = h4 ^ Math.imul(h3 ^ k, 951274213);
17
+ h4 = h1 ^ Math.imul(h4 ^ k, 2716044179);
18
+ }
19
+ h1 = Math.imul(h3 ^ (h1 >>> 18), 597399067);
20
+ h2 = Math.imul(h4 ^ (h2 >>> 22), 2869860233);
21
+ h3 = Math.imul(h1 ^ (h3 >>> 17), 951274213);
22
+ h4 = Math.imul(h2 ^ (h4 >>> 19), 2716044179);
23
+ return [
24
+ (h1 ^ h2 ^ h3 ^ h4) >>> 0,
25
+ (h2 ^ h1) >>> 0,
26
+ (h3 ^ h1) >>> 0,
27
+ (h4 ^ h1) >>> 0
28
+ ];
29
+ }
30
+ /**
31
+ * Simple Fast Counter
32
+ * 128-bit state PRNG
33
+ *
34
+ * @param {number} a
35
+ * @param {number} b
36
+ * @param {number} c
37
+ * @param {number} d
38
+ * @returns {number}
39
+ */
40
+ export function sfc32(a, b, c, d) {
41
+ a >>>= 0;
42
+ b >>>= 0;
43
+ c >>>= 0;
44
+ d >>>= 0;
45
+ let t = (a + b | 0) + d | 0;
46
+ d = d + 1 | 0;
47
+ a = b ^ b >>> 9;
48
+ b = c + (c << 3) | 0;
49
+ c = (c << 21 | c >>> 11);
50
+ c = c + t | 0;
51
+ return (t >>> 0) / 4294967296;
52
+ }
53
+ /**
54
+ * Jenkins' Small Fast
55
+ * 128-bit state PRNG
56
+ *
57
+ * @param {number} a
58
+ * @param {number} b
59
+ * @param {number} c
60
+ * @param {number} d
61
+ * @returns {number}
62
+ */
63
+ export function jsf32(a, b, c, d) {
64
+ a |= 0;
65
+ b |= 0;
66
+ c |= 0;
67
+ d |= 0;
68
+ let t = (a - ((b << 27) | (b >>> 5))) | 0;
69
+ a = b ^ ((c << 17) | (c >>> 15));
70
+ b = (c + d) | 0;
71
+ c = (d + t) | 0;
72
+ d = (a + t) | 0;
73
+ return (d >>> 0) / 4294967296;
74
+ }
75
+ /**
76
+ * xoshiro128**
77
+ * 128-bit state PRNG
78
+ *
79
+ * @param {number} a
80
+ * @param {number} b
81
+ * @param {number} c
82
+ * @param {number} d
83
+ * @returns {number}
84
+ */
85
+ export function xoshiro128ss(a, b, c, d) {
86
+ let t = b << 9;
87
+ let r = a * 5;
88
+ r = ((r << 7) | (r >>> 25)) * 9;
89
+ c ^= a;
90
+ d ^= b;
91
+ b ^= c;
92
+ a ^= d;
93
+ c ^= t;
94
+ d = (d << 11) | (d >>> 21);
95
+ return (r >>> 0) / 4294967296;
96
+ }
97
+ /**
98
+ * Mulberry32
99
+ * 32-bit state PRNG
100
+ *
101
+ * @param {number} a
102
+ * @returns {number}
103
+ */
104
+ export function mulberry32(a) {
105
+ let t = (a += 0x6d2b79f5);
106
+ t = Math.imul(t ^ (t >>> 15), t | 1);
107
+ t ^= t + Math.imul(t ^ (t >>> 7), t | 61);
108
+ return ((t ^ (t >>> 14)) >>> 0) / 4294967296;
109
+ }
110
+ /**
111
+ * SplitMix
112
+ * 32-bit state PRNG
113
+ *
114
+ * @param {number} a
115
+ * @returns {number}
116
+ */
117
+ export function splitmix32(a) {
118
+ a |= 0;
119
+ a = (a + 0x9e3779b9) | 0;
120
+ var t = a ^ (a >>> 16);
121
+ t = Math.imul(t, 0x21f0aaad);
122
+ t = t ^ (t >>> 15);
123
+ t = Math.imul(t, 0x735a2d97);
124
+ return ((t = t ^ (t >>> 15)) >>> 0) / 4294967296;
125
+ }
package/lib/index.d.ts CHANGED
@@ -1,2 +1,5 @@
1
+ export { DEFAULT_SEED } from './constants';
2
+ export { cyrb128, sfc32, jsf32, xoshiro128ss, splitmix32, mulberry32 } from './generators';
3
+ export { randomSeed } from './utils';
1
4
  export { default, PRNG } from './prng';
2
5
  export type * from './types';
package/lib/index.js CHANGED
@@ -1 +1,4 @@
1
+ export { DEFAULT_SEED } from './constants';
2
+ export { cyrb128, sfc32, jsf32, xoshiro128ss, splitmix32, mulberry32 } from './generators';
3
+ export { randomSeed } from './utils';
1
4
  export { default, PRNG } from './prng';
package/lib/prng.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { AlgorithmFunction, AlgorithmName } from './types';
1
+ import type { Seed, Generator } from './types';
2
2
  /**
3
3
  * Utility class for generating pseudo-random values
4
4
  *
@@ -6,114 +6,110 @@ import { AlgorithmFunction, AlgorithmName } from './types';
6
6
  * @exports
7
7
  */
8
8
  export declare class PRNG {
9
- protected _seed: string;
10
- protected _algorithm: AlgorithmFunction;
11
- get seed(): string | number;
12
- set seed(seed: string | number);
13
- get algorithm(): AlgorithmFunction;
14
- set algorithm(algorithm: AlgorithmFunction);
15
9
  /**
16
- * Set this PRNG seed
17
- *
18
- * @param {string|number} seed
10
+ * Seed string used for pseudo-random generations
11
+ */
12
+ seed: string;
13
+ /**
14
+ * Generator function used for pseudo-random generations
15
+ */
16
+ readonly generator: Generator;
17
+ /**
18
+ * @param {Seed} [seed] Seed string used for pseudo-random generations
19
+ * @param {Generator} [generator=sfc32] Generator function used for pseudo-random generations
19
20
  */
20
- setSeed(seed: string | number): void;
21
+ constructor(seed?: Seed, generator?: Generator);
21
22
  /**
22
- * Set this PRNG algorithm
23
+ * Set this PRNG seed
23
24
  *
24
- * @param {AlgorithmName} algorithmName Algorithm name
25
+ * @param {Seed} seed
25
26
  */
26
- setAlgorithm(algorithmName: AlgorithmName): void;
27
+ setSeed(seed?: Seed): void;
27
28
  /**
28
- * Generate a pseudo-random number in the interval [0, 1]
29
- * PRNG equivalent of `Math.random()`
29
+ * Generate a pseudo-random number between 0 and 1 (0 inclusive, 1 exclusive)
30
+ * Pseudo-random equivalent of `Math.random()`
30
31
  *
31
- * @param {string|number} seed
32
- * @returns {number}
32
+ * @param {Seed} subseed
33
+ * @returns {number} Generated pseudo-random number between `0` and `1`
33
34
  */
34
- random(seed: string | number): number;
35
+ random(subseed: Seed): number;
35
36
  /**
36
37
  * Generate a pseudo-random boolean (true or false)
37
38
  *
38
- * @param {string|number} seed
39
+ * @param {Seed} subseed
39
40
  * @param {number} [probability=0.5] Probability to get `true`
40
41
  * @returns {boolean} Either `true` or `false`
41
42
  */
42
- randomBoolean(seed: string | number, probability?: number): boolean;
43
+ randomBoolean(subseed: Seed, probability?: number): boolean;
43
44
  /**
44
45
  * Generate a pseudo-random sign (1 or -1)
45
46
  *
46
- * @param {string|number} seed
47
- * @param {number} [probability=0.5] Probability to get 1
48
- * @returns {number} Either 1 or -1
47
+ * @param {Seed} subseed
48
+ * @param {number} [probability=0.5] Probability to get `1`
49
+ * @returns {number} Either `1` or `-1`
49
50
  */
50
- randomSign(seed: string | number, probability?: number): number;
51
+ randomSign(subseed: Seed, probability?: number): number;
51
52
  /**
52
53
  * Generate a pseudo-random floating-point number within a specified range
53
54
  *
54
- * @param {string|number} seed
55
- * @param {number} [min=0] Minimum boundary
56
- * @param {number} [max=1] Maximum boundary
55
+ * @param {Seed} subseed
56
+ * @param {number} [min=0] Minimum boundary
57
+ * @param {number} [max=1] Maximum boundary
57
58
  * @param {number} [precision=2] Number of digits after the decimal point
58
- * @returns {number} Generated float
59
+ * @returns {number} Generated floating-point number
59
60
  */
60
- randomFloat(seed: string | number, min?: number, max?: number, precision?: number): number;
61
+ randomFloat(subseed: Seed, min?: number, max?: number, precision?: number): number;
61
62
  /**
62
63
  * Generate a pseudo-random integer number within a specified range
63
64
  *
64
- * @param {string|number} seed
65
+ * @param {Seed} subseed
65
66
  * @param {number} min Minimum boundary
66
67
  * @param {number} max Maximum boundary
67
- * @returns {number} Generated integer
68
+ * @returns {number} Generated integer number
68
69
  */
69
- randomInt(seed: string | number, min: number, max: number): number;
70
+ randomInt(subseed: Seed, min: number, max: number): number;
70
71
  /**
71
72
  * Generate a pseudo-random hexadecimal color
72
73
  *
73
- * @param {string|number} seed
74
+ * @param {Seed} subseed
74
75
  * @returns {string} Generated hexadecimal color
75
76
  */
76
- randomHexColor(seed: string | number): string;
77
+ randomHexColor(subseed: Seed): string;
77
78
  /**
78
- * Pick a pseudo-random item from a given array
79
+ * Pseudo-randomly pick an item from an array
79
80
  *
80
- * @param {string|number} seed
81
+ * @template [T=unknown]
82
+ * @param {Seed} subseed
81
83
  * @param {T[]} array Array to pick the item from
82
- * @returns {T|undefined} Random item picked
84
+ * @returns {T|undefined} Item picked
83
85
  */
84
- randomItem<T = unknown>(seed: string | number, array: T[]): T | undefined;
86
+ randomItem<T = unknown>(subseed: Seed, array: T[]): T | undefined;
85
87
  /**
86
- * Pick a pseudo-random property value from a given object
88
+ * Pseudo-randomly pick a property value from an object
87
89
  *
88
- * @param {string|number} seed
90
+ * @template [T=unknown]
91
+ * @param {Seed} subseed
89
92
  * @param {object} object Object to pick the property from
90
- * @returns {T|undefined} Random item picked
93
+ * @returns {T|undefined} Pseudo-random property value picked
91
94
  */
92
- randomObjectProperty<T = unknown>(seed: string | number, object: Record<string, T>): T | undefined;
95
+ randomObjectProperty<T = unknown>(subseed: Seed, object: Record<string, T>): T | undefined;
93
96
  /**
94
97
  * Select a pseudo-random index from an array of weighted items
95
98
  *
96
- * @param {string|number} seed
99
+ * @param {Seed} subseed
97
100
  * @param {number[]} weights Array of weights
98
- * @returns {number} Random index based on weights
101
+ * @returns {number} Pseudo-random index based on weights
99
102
  */
100
- randomIndex(seed: string | number, weights: number[]): number;
103
+ randomIndex(subseed: Seed, weights: number[]): number;
101
104
  /**
102
105
  * Generate a pseudo-random number fitting a Gaussian (normal) distribution
103
106
  *
104
- * @param {string|number} seed
105
- * @param {number} [mean=0] Central value
106
- * @param {number} [spread=1] Standard deviation
107
- * @returns Generated number
108
- */
109
- randomGaussian(seed: string | number, mean?: number, spread?: number): number;
110
- /**
111
- * Get the PRNG algorithm function by its name
112
- *
113
- * @param {AlgorithmName} algorithmName Algorithm name
114
- * @returns {Function} PRNG algorithm function
107
+ * @param {Seed} subseed
108
+ * @param {number} [mean=0] Mean (central) value of the distribution
109
+ * @param {number} [spread=1] Spread (standard deviation) of the distribution
110
+ * @returns {number} Generated number
115
111
  */
116
- protected getAlgorithmByName(algorithmName: AlgorithmName): (...args: number[]) => number;
112
+ randomGaussian(subseed: Seed, mean?: number, spread?: number): number;
117
113
  }
118
114
  declare const prng: PRNG;
119
115
  export default prng;
package/lib/prng.js CHANGED
@@ -1,5 +1,6 @@
1
- import { cyrb128, jsf32, mulberry32, sfc32, splitmix32, xoshiro128ss } from 'toosoon-utils/prng';
2
- import { AlgorithmName } from './types';
1
+ import { DEFAULT_SEED } from './constants';
2
+ import { cyrb128, sfc32 } from './generators';
3
+ import { randomSeed } from './utils';
3
4
  /**
4
5
  * Utility class for generating pseudo-random values
5
6
  *
@@ -7,121 +8,117 @@ import { AlgorithmName } from './types';
7
8
  * @exports
8
9
  */
9
10
  export class PRNG {
10
- _seed = '';
11
- _algorithm = splitmix32;
12
- get seed() {
13
- return this._seed;
14
- }
15
- set seed(seed) {
16
- this._seed = `${seed}`;
17
- }
18
- get algorithm() {
19
- return this._algorithm;
20
- }
21
- set algorithm(algorithm) {
22
- this._algorithm = algorithm;
23
- }
24
11
  /**
25
- * Set this PRNG seed
26
- *
27
- * @param {string|number} seed
12
+ * Seed string used for pseudo-random generations
13
+ */
14
+ seed = '';
15
+ /**
16
+ * Generator function used for pseudo-random generations
28
17
  */
29
- setSeed(seed) {
18
+ generator;
19
+ /**
20
+ * @param {Seed} [seed] Seed string used for pseudo-random generations
21
+ * @param {Generator} [generator=sfc32] Generator function used for pseudo-random generations
22
+ */
23
+ constructor(seed = randomSeed(), generator = sfc32) {
30
24
  this.seed = `${seed}`;
25
+ this.generator = generator;
31
26
  }
32
27
  /**
33
- * Set this PRNG algorithm
28
+ * Set this PRNG seed
34
29
  *
35
- * @param {AlgorithmName} algorithmName Algorithm name
30
+ * @param {Seed} seed
36
31
  */
37
- setAlgorithm(algorithmName) {
38
- this.algorithm = this.getAlgorithmByName(algorithmName);
32
+ setSeed(seed = randomSeed()) {
33
+ this.seed = `${seed}`;
39
34
  }
40
35
  /**
41
- * Generate a pseudo-random number in the interval [0, 1]
42
- * PRNG equivalent of `Math.random()`
36
+ * Generate a pseudo-random number between 0 and 1 (0 inclusive, 1 exclusive)
37
+ * Pseudo-random equivalent of `Math.random()`
43
38
  *
44
- * @param {string|number} seed
45
- * @returns {number}
39
+ * @param {Seed} subseed
40
+ * @returns {number} Generated pseudo-random number between `0` and `1`
46
41
  */
47
- random(seed) {
48
- const hashes = cyrb128(this.seed + `${seed}`);
49
- return this.algorithm(...hashes);
42
+ random(subseed) {
43
+ const hashes = cyrb128(this.seed + `${subseed}`);
44
+ return this.generator(...hashes);
50
45
  }
51
46
  /**
52
47
  * Generate a pseudo-random boolean (true or false)
53
48
  *
54
- * @param {string|number} seed
49
+ * @param {Seed} subseed
55
50
  * @param {number} [probability=0.5] Probability to get `true`
56
51
  * @returns {boolean} Either `true` or `false`
57
52
  */
58
- randomBoolean(seed, probability = 0.5) {
59
- return this.random(seed) < probability;
53
+ randomBoolean(subseed, probability = 0.5) {
54
+ return this.random(subseed) < probability;
60
55
  }
61
56
  /**
62
57
  * Generate a pseudo-random sign (1 or -1)
63
58
  *
64
- * @param {string|number} seed
65
- * @param {number} [probability=0.5] Probability to get 1
66
- * @returns {number} Either 1 or -1
59
+ * @param {Seed} subseed
60
+ * @param {number} [probability=0.5] Probability to get `1`
61
+ * @returns {number} Either `1` or `-1`
67
62
  */
68
- randomSign(seed, probability = 0.5) {
69
- return this.randomBoolean(seed, probability) ? 1 : -1;
63
+ randomSign(subseed, probability = 0.5) {
64
+ return this.randomBoolean(subseed, probability) ? 1 : -1;
70
65
  }
71
66
  /**
72
67
  * Generate a pseudo-random floating-point number within a specified range
73
68
  *
74
- * @param {string|number} seed
75
- * @param {number} [min=0] Minimum boundary
76
- * @param {number} [max=1] Maximum boundary
69
+ * @param {Seed} subseed
70
+ * @param {number} [min=0] Minimum boundary
71
+ * @param {number} [max=1] Maximum boundary
77
72
  * @param {number} [precision=2] Number of digits after the decimal point
78
- * @returns {number} Generated float
73
+ * @returns {number} Generated floating-point number
79
74
  */
80
- randomFloat(seed, min = 0, max = 1, precision = 2) {
81
- return parseFloat(Math.min(min + this.random(seed) * (max - min), max).toFixed(precision));
75
+ randomFloat(subseed, min = 0, max = 1, precision = 2) {
76
+ return parseFloat(Math.min(min + this.random(subseed) * (max - min), max).toFixed(precision));
82
77
  }
83
78
  /**
84
79
  * Generate a pseudo-random integer number within a specified range
85
80
  *
86
- * @param {string|number} seed
81
+ * @param {Seed} subseed
87
82
  * @param {number} min Minimum boundary
88
83
  * @param {number} max Maximum boundary
89
- * @returns {number} Generated integer
84
+ * @returns {number} Generated integer number
90
85
  */
91
- randomInt(seed, min, max) {
92
- return Math.floor(this.random(seed) * (max - min + 1) + min);
86
+ randomInt(subseed, min, max) {
87
+ return Math.floor(this.random(subseed) * (max - min + 1) + min);
93
88
  }
94
89
  /**
95
90
  * Generate a pseudo-random hexadecimal color
96
91
  *
97
- * @param {string|number} seed
92
+ * @param {Seed} subseed
98
93
  * @returns {string} Generated hexadecimal color
99
94
  */
100
- randomHexColor(seed) {
101
- return '#' + ('00000' + ((this.random(seed) * (1 << 24)) | 0).toString(16)).slice(-6);
95
+ randomHexColor(subseed) {
96
+ return '#' + ('00000' + ((this.random(subseed) * (1 << 24)) | 0).toString(16)).slice(-6);
102
97
  }
103
98
  /**
104
- * Pick a pseudo-random item from a given array
99
+ * Pseudo-randomly pick an item from an array
105
100
  *
106
- * @param {string|number} seed
101
+ * @template [T=unknown]
102
+ * @param {Seed} subseed
107
103
  * @param {T[]} array Array to pick the item from
108
- * @returns {T|undefined} Random item picked
104
+ * @returns {T|undefined} Item picked
109
105
  */
110
- randomItem(seed, array) {
106
+ randomItem(subseed, array) {
111
107
  if (array.length === 0)
112
108
  return undefined;
113
- return array[this.randomInt(seed, 0, array.length - 1)];
109
+ return array[this.randomInt(subseed, 0, array.length - 1)];
114
110
  }
115
111
  /**
116
- * Pick a pseudo-random property value from a given object
112
+ * Pseudo-randomly pick a property value from an object
117
113
  *
118
- * @param {string|number} seed
114
+ * @template [T=unknown]
115
+ * @param {Seed} subseed
119
116
  * @param {object} object Object to pick the property from
120
- * @returns {T|undefined} Random item picked
117
+ * @returns {T|undefined} Pseudo-random property value picked
121
118
  */
122
- randomObjectProperty(seed, object) {
119
+ randomObjectProperty(subseed, object) {
123
120
  const keys = Object.keys(object);
124
- const key = this.randomItem(seed, keys);
121
+ const key = this.randomItem(subseed, keys);
125
122
  if (key && object.hasOwnProperty(key)) {
126
123
  return object[key];
127
124
  }
@@ -129,11 +126,11 @@ export class PRNG {
129
126
  /**
130
127
  * Select a pseudo-random index from an array of weighted items
131
128
  *
132
- * @param {string|number} seed
129
+ * @param {Seed} subseed
133
130
  * @param {number[]} weights Array of weights
134
- * @returns {number} Random index based on weights
131
+ * @returns {number} Pseudo-random index based on weights
135
132
  */
136
- randomIndex(seed, weights) {
133
+ randomIndex(subseed, weights) {
137
134
  if (weights.length === 0)
138
135
  return -1;
139
136
  let totalWeight = 0;
@@ -142,7 +139,7 @@ export class PRNG {
142
139
  }
143
140
  if (totalWeight <= 0)
144
141
  console.warn('PRNG.randomIndex()', 'Weights must sum to > 0', totalWeight);
145
- let weight = this.random(seed) * totalWeight;
142
+ let weight = this.random(subseed) * totalWeight;
146
143
  for (let i = 0; i < weights.length; i++) {
147
144
  if (weight < weights[i])
148
145
  return i;
@@ -153,38 +150,18 @@ export class PRNG {
153
150
  /**
154
151
  * Generate a pseudo-random number fitting a Gaussian (normal) distribution
155
152
  *
156
- * @param {string|number} seed
157
- * @param {number} [mean=0] Central value
158
- * @param {number} [spread=1] Standard deviation
159
- * @returns Generated number
153
+ * @param {Seed} subseed
154
+ * @param {number} [mean=0] Mean (central) value of the distribution
155
+ * @param {number} [spread=1] Spread (standard deviation) of the distribution
156
+ * @returns {number} Generated number
160
157
  */
161
- randomGaussian(seed, mean = 0, spread = 1) {
162
- const hashes = cyrb128(this.seed + `${seed}`);
163
- const u = this.algorithm(hashes[0] + hashes[1]);
164
- const v = this.algorithm(hashes[2] + hashes[3]);
158
+ randomGaussian(subseed, mean = 0, spread = 1) {
159
+ const hashes = cyrb128(this.seed + `${subseed}`);
160
+ const u = this.generator(hashes[0], hashes[1], hashes[2], hashes[3]);
161
+ const v = this.generator(hashes[3], hashes[2], hashes[1], hashes[0]);
165
162
  const z = Math.sqrt(-2.0 * Math.log(u)) * Math.cos(2.0 * Math.PI * v);
166
163
  return mean + z * spread;
167
164
  }
168
- /**
169
- * Get the PRNG algorithm function by its name
170
- *
171
- * @param {AlgorithmName} algorithmName Algorithm name
172
- * @returns {Function} PRNG algorithm function
173
- */
174
- getAlgorithmByName(algorithmName) {
175
- switch (algorithmName) {
176
- case AlgorithmName.jsf32:
177
- return jsf32;
178
- case AlgorithmName.mulberry32:
179
- return mulberry32;
180
- case AlgorithmName.sfc32:
181
- return sfc32;
182
- case AlgorithmName.splitmix32:
183
- return splitmix32;
184
- case AlgorithmName.xoshiro128ss:
185
- return xoshiro128ss;
186
- }
187
- }
188
165
  }
189
- const prng = new PRNG();
166
+ const prng = new PRNG(DEFAULT_SEED);
190
167
  export default prng;
@@ -1 +1 @@
1
- {"program":{"fileNames":["../node_modules/typescript/lib/lib.es5.d.ts","../node_modules/typescript/lib/lib.es2015.d.ts","../node_modules/typescript/lib/lib.es2016.d.ts","../node_modules/typescript/lib/lib.es2017.d.ts","../node_modules/typescript/lib/lib.es2018.d.ts","../node_modules/typescript/lib/lib.es2019.d.ts","../node_modules/typescript/lib/lib.es2020.d.ts","../node_modules/typescript/lib/lib.es2021.d.ts","../node_modules/typescript/lib/lib.es2022.d.ts","../node_modules/typescript/lib/lib.es2023.d.ts","../node_modules/typescript/lib/lib.esnext.d.ts","../node_modules/typescript/lib/lib.dom.d.ts","../node_modules/typescript/lib/lib.dom.iterable.d.ts","../node_modules/typescript/lib/lib.es2015.core.d.ts","../node_modules/typescript/lib/lib.es2015.collection.d.ts","../node_modules/typescript/lib/lib.es2015.generator.d.ts","../node_modules/typescript/lib/lib.es2015.iterable.d.ts","../node_modules/typescript/lib/lib.es2015.promise.d.ts","../node_modules/typescript/lib/lib.es2015.proxy.d.ts","../node_modules/typescript/lib/lib.es2015.reflect.d.ts","../node_modules/typescript/lib/lib.es2015.symbol.d.ts","../node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts","../node_modules/typescript/lib/lib.es2016.array.include.d.ts","../node_modules/typescript/lib/lib.es2016.intl.d.ts","../node_modules/typescript/lib/lib.es2017.date.d.ts","../node_modules/typescript/lib/lib.es2017.object.d.ts","../node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts","../node_modules/typescript/lib/lib.es2017.string.d.ts","../node_modules/typescript/lib/lib.es2017.intl.d.ts","../node_modules/typescript/lib/lib.es2017.typedarrays.d.ts","../node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts","../node_modules/typescript/lib/lib.es2018.asynciterable.d.ts","../node_modules/typescript/lib/lib.es2018.intl.d.ts","../node_modules/typescript/lib/lib.es2018.promise.d.ts","../node_modules/typescript/lib/lib.es2018.regexp.d.ts","../node_modules/typescript/lib/lib.es2019.array.d.ts","../node_modules/typescript/lib/lib.es2019.object.d.ts","../node_modules/typescript/lib/lib.es2019.string.d.ts","../node_modules/typescript/lib/lib.es2019.symbol.d.ts","../node_modules/typescript/lib/lib.es2019.intl.d.ts","../node_modules/typescript/lib/lib.es2020.bigint.d.ts","../node_modules/typescript/lib/lib.es2020.date.d.ts","../node_modules/typescript/lib/lib.es2020.promise.d.ts","../node_modules/typescript/lib/lib.es2020.sharedmemory.d.ts","../node_modules/typescript/lib/lib.es2020.string.d.ts","../node_modules/typescript/lib/lib.es2020.symbol.wellknown.d.ts","../node_modules/typescript/lib/lib.es2020.intl.d.ts","../node_modules/typescript/lib/lib.es2020.number.d.ts","../node_modules/typescript/lib/lib.es2021.promise.d.ts","../node_modules/typescript/lib/lib.es2021.string.d.ts","../node_modules/typescript/lib/lib.es2021.weakref.d.ts","../node_modules/typescript/lib/lib.es2021.intl.d.ts","../node_modules/typescript/lib/lib.es2022.array.d.ts","../node_modules/typescript/lib/lib.es2022.error.d.ts","../node_modules/typescript/lib/lib.es2022.intl.d.ts","../node_modules/typescript/lib/lib.es2022.object.d.ts","../node_modules/typescript/lib/lib.es2022.sharedmemory.d.ts","../node_modules/typescript/lib/lib.es2022.string.d.ts","../node_modules/typescript/lib/lib.es2022.regexp.d.ts","../node_modules/typescript/lib/lib.es2023.array.d.ts","../node_modules/typescript/lib/lib.es2023.collection.d.ts","../node_modules/typescript/lib/lib.esnext.collection.d.ts","../node_modules/typescript/lib/lib.esnext.intl.d.ts","../node_modules/typescript/lib/lib.esnext.disposable.d.ts","../node_modules/typescript/lib/lib.esnext.promise.d.ts","../node_modules/typescript/lib/lib.esnext.decorators.d.ts","../node_modules/typescript/lib/lib.esnext.object.d.ts","../node_modules/typescript/lib/lib.decorators.d.ts","../node_modules/typescript/lib/lib.decorators.legacy.d.ts","../node_modules/toosoon-utils/lib/prng.d.ts","../src/types.ts","../src/prng.ts","../src/index.ts"],"fileInfos":[{"version":"824cb491a40f7e8fdeb56f1df5edf91b23f3e3ee6b4cde84d4a99be32338faee","affectsGlobalScope":true},"45b7ab580deca34ae9729e97c13cfd999df04416a79116c3bfb483804f85ded4","3facaf05f0c5fc569c5649dd359892c98a85557e3e0c847964caeb67076f4d75","9a68c0c07ae2fa71b44384a839b7b8d81662a236d4b9ac30916718f7510b1b2d","5e1c4c362065a6b95ff952c0eab010f04dcd2c3494e813b493ecfd4fcb9fc0d8","68d73b4a11549f9c0b7d352d10e91e5dca8faa3322bfb77b661839c42b1ddec7","5efce4fc3c29ea84e8928f97adec086e3dc876365e0982cc8479a07954a3efd4","feecb1be483ed332fad555aff858affd90a48ab19ba7272ee084704eb7167569","5514e54f17d6d74ecefedc73c504eadffdeda79c7ea205cf9febead32d45c4bc","1c0cdb8dc619bc549c3e5020643e7cf7ae7940058e8c7e5aefa5871b6d86f44b","886e50ef125efb7878f744e86908884c0133e7a6d9d80013f421b0cd8fb2af94",{"version":"87d693a4920d794a73384b3c779cadcb8548ac6945aa7a925832fe2418c9527a","affectsGlobalScope":true},{"version":"76f838d5d49b65de83bc345c04aa54c62a3cfdb72a477dc0c0fce89a30596c30","affectsGlobalScope":true},{"version":"138fb588d26538783b78d1e3b2c2cc12d55840b97bf5e08bca7f7a174fbe2f17","affectsGlobalScope":true},{"version":"dc2df20b1bcdc8c2d34af4926e2c3ab15ffe1160a63e58b7e09833f616efff44","affectsGlobalScope":true},{"version":"4443e68b35f3332f753eacc66a04ac1d2053b8b035a0e0ac1d455392b5e243b3","affectsGlobalScope":true},{"version":"bc47685641087c015972a3f072480889f0d6c65515f12bd85222f49a98952ed7","affectsGlobalScope":true},{"version":"0dc1e7ceda9b8b9b455c3a2d67b0412feab00bd2f66656cd8850e8831b08b537","affectsGlobalScope":true},{"version":"ce691fb9e5c64efb9547083e4a34091bcbe5bdb41027e310ebba8f7d96a98671","affectsGlobalScope":true},{"version":"8d697a2a929a5fcb38b7a65594020fcef05ec1630804a33748829c5ff53640d0","affectsGlobalScope":true},{"version":"4ff2a353abf8a80ee399af572debb8faab2d33ad38c4b4474cff7f26e7653b8d","affectsGlobalScope":true},{"version":"93495ff27b8746f55d19fcbcdbaccc99fd95f19d057aed1bd2c0cafe1335fbf0","affectsGlobalScope":true},{"version":"6fc23bb8c3965964be8c597310a2878b53a0306edb71d4b5a4dfe760186bcc01","affectsGlobalScope":true},{"version":"ea011c76963fb15ef1cdd7ce6a6808b46322c527de2077b6cfdf23ae6f5f9ec7","affectsGlobalScope":true},{"version":"38f0219c9e23c915ef9790ab1d680440d95419ad264816fa15009a8851e79119","affectsGlobalScope":true},{"version":"bb42a7797d996412ecdc5b2787720de477103a0b2e53058569069a0e2bae6c7e","affectsGlobalScope":true},{"version":"4738f2420687fd85629c9efb470793bb753709c2379e5f85bc1815d875ceadcd","affectsGlobalScope":true},{"version":"2f11ff796926e0832f9ae148008138ad583bd181899ab7dd768a2666700b1893","affectsGlobalScope":true},{"version":"4de680d5bb41c17f7f68e0419412ca23c98d5749dcaaea1896172f06435891fc","affectsGlobalScope":true},{"version":"9fc46429fbe091ac5ad2608c657201eb68b6f1b8341bd6d670047d32ed0a88fa","affectsGlobalScope":true},{"version":"61c37c1de663cf4171e1192466e52c7a382afa58da01b1dc75058f032ddf0839","affectsGlobalScope":true},{"version":"b541a838a13f9234aba650a825393ffc2292dc0fc87681a5d81ef0c96d281e7a","affectsGlobalScope":true},{"version":"b20fe0eca9a4e405f1a5ae24a2b3290b37cf7f21eba6cbe4fc3fab979237d4f3","affectsGlobalScope":true},{"version":"811ec78f7fefcabbda4bfa93b3eb67d9ae166ef95f9bff989d964061cbf81a0c","affectsGlobalScope":true},{"version":"717937616a17072082152a2ef351cb51f98802fb4b2fdabd32399843875974ca","affectsGlobalScope":true},{"version":"d7e7d9b7b50e5f22c915b525acc5a49a7a6584cf8f62d0569e557c5cfc4b2ac2","affectsGlobalScope":true},{"version":"71c37f4c9543f31dfced6c7840e068c5a5aacb7b89111a4364b1d5276b852557","affectsGlobalScope":true},{"version":"576711e016cf4f1804676043e6a0a5414252560eb57de9faceee34d79798c850","affectsGlobalScope":true},{"version":"89c1b1281ba7b8a96efc676b11b264de7a8374c5ea1e6617f11880a13fc56dc6","affectsGlobalScope":true},{"version":"49ed889be54031e1044af0ad2c603d627b8bda8b50c1a68435fe85583901d072","affectsGlobalScope":true},{"version":"e93d098658ce4f0c8a0779e6cab91d0259efb88a318137f686ad76f8410ca270","affectsGlobalScope":true},{"version":"063600664504610fe3e99b717a1223f8b1900087fab0b4cad1496a114744f8df","affectsGlobalScope":true},{"version":"934019d7e3c81950f9a8426d093458b65d5aff2c7c1511233c0fd5b941e608ab","affectsGlobalScope":true},{"version":"bf14a426dbbf1022d11bd08d6b8e709a2e9d246f0c6c1032f3b2edb9a902adbe","affectsGlobalScope":true},{"version":"5e07ed3809d48205d5b985642a59f2eba47c402374a7cf8006b686f79efadcbd","affectsGlobalScope":true},{"version":"2b72d528b2e2fe3c57889ca7baef5e13a56c957b946906d03767c642f386bbc3","affectsGlobalScope":true},{"version":"8073890e29d2f46fdbc19b8d6d2eb9ea58db9a2052f8640af20baff9afbc8640","affectsGlobalScope":true},{"version":"368af93f74c9c932edd84c58883e736c9e3d53cec1fe24c0b0ff451f529ceab1","affectsGlobalScope":true},{"version":"af3dd424cf267428f30ccfc376f47a2c0114546b55c44d8c0f1d57d841e28d74","affectsGlobalScope":true},{"version":"995c005ab91a498455ea8dfb63aa9f83fa2ea793c3d8aa344be4a1678d06d399","affectsGlobalScope":true},{"version":"51e547984877a62227042850456de71a5c45e7fe86b7c975c6e68896c86fa23b","affectsGlobalScope":true},{"version":"956d27abdea9652e8368ce029bb1e0b9174e9678a273529f426df4b3d90abd60","affectsGlobalScope":true},{"version":"4fa6ed14e98aa80b91f61b9805c653ee82af3502dc21c9da5268d3857772ca05","affectsGlobalScope":true},{"version":"e6633e05da3ff36e6da2ec170d0d03ccf33de50ca4dc6f5aeecb572cedd162fb","affectsGlobalScope":true},{"version":"d8670852241d4c6e03f2b89d67497a4bbefe29ecaa5a444e2c11a9b05e6fccc6","affectsGlobalScope":true},{"version":"8444af78980e3b20b49324f4a16ba35024fef3ee069a0eb67616ea6ca821c47a","affectsGlobalScope":true},{"version":"caccc56c72713969e1cfe5c3d44e5bab151544d9d2b373d7dbe5a1e4166652be","affectsGlobalScope":true},{"version":"3287d9d085fbd618c3971944b65b4be57859f5415f495b33a6adc994edd2f004","affectsGlobalScope":true},{"version":"50d53ccd31f6667aff66e3d62adf948879a3a16f05d89882d1188084ee415bbc","affectsGlobalScope":true},{"version":"08a58483392df5fcc1db57d782e87734f77ae9eab42516028acbfe46f29a3ef7","affectsGlobalScope":true},{"version":"436aaf437562f276ec2ddbee2f2cdedac7664c1e4c1d2c36839ddd582eeb3d0a","affectsGlobalScope":true},{"version":"b1cb28af0c891c8c96b2d6b7be76bd394fddcfdb4709a20ba05a7c1605eea0f9","affectsGlobalScope":true},{"version":"13f6e6380c78e15e140243dc4be2fa546c287c6d61f4729bc2dd7cf449605471","affectsGlobalScope":true},{"version":"15b98a533864d324e5f57cd3cfc0579b231df58c1c0f6063ea0fcb13c3c74ff9","affectsGlobalScope":true},{"version":"ac77cb3e8c6d3565793eb90a8373ee8033146315a3dbead3bde8db5eaf5e5ec6","affectsGlobalScope":true},{"version":"d4b1d2c51d058fc21ec2629fff7a76249dec2e36e12960ea056e3ef89174080f","affectsGlobalScope":true},{"version":"2fef54945a13095fdb9b84f705f2b5994597640c46afeb2ce78352fab4cb3279","affectsGlobalScope":true},{"version":"33358442698bb565130f52ba79bfd3d4d484ac85fe33f3cb1759c54d18201393","affectsGlobalScope":true},{"version":"782dec38049b92d4e85c1585fbea5474a219c6984a35b004963b00beb1aab538","affectsGlobalScope":true},"3244739232ed0f77eb4aa4cd9af4feddcf5c3eabdf4f6c3388a5a75569935adb",{"version":"0c162dad72573d233d13195e3b80fed773694e9677b525d9fa22f34d660fe7a9","signature":"aca3e00c7103e529286ca739994f17f821acdbdad539c2be48312dbe529a85fa"},{"version":"459a0e96cb1da14cfd2a81d944b21098d48de670346eaaf2ea377f7831656132","signature":"217968e68843a319adba2493b7af7bcf6a7e100b69cc478454466deb3c3e9a36"},{"version":"e4035c130e9e1e9c9462141cf3af38879f74d9653e70c7585e0cec14a3fee8a4","signature":"f9ca5cc1b894f1a19cbb55135cbfa308ad994ef06e1412e04ff1796272a93b89"}],"root":[[71,73]],"options":{"allowJs":true,"checkJs":true,"declaration":true,"module":99,"outDir":"./","skipLibCheck":true,"strict":true,"target":99},"fileIdsList":[[71,72],[70,71],[71]],"referencedMap":[[73,1],[72,2]],"exportedModulesMap":[[73,1],[72,3]],"semanticDiagnosticsPerFile":[70,68,69,12,13,15,14,2,16,17,18,19,20,21,22,23,3,24,4,25,29,26,27,28,30,31,32,5,33,34,35,36,6,40,37,38,39,41,7,42,47,48,43,44,45,46,8,52,49,50,51,53,9,54,55,56,59,57,58,60,61,10,1,62,11,66,64,63,67,65,73,72,71]},"version":"5.4.2"}
1
+ {"program":{"fileNames":["../node_modules/typescript/lib/lib.es5.d.ts","../node_modules/typescript/lib/lib.es2015.d.ts","../node_modules/typescript/lib/lib.es2016.d.ts","../node_modules/typescript/lib/lib.es2017.d.ts","../node_modules/typescript/lib/lib.es2018.d.ts","../node_modules/typescript/lib/lib.es2019.d.ts","../node_modules/typescript/lib/lib.es2020.d.ts","../node_modules/typescript/lib/lib.es2021.d.ts","../node_modules/typescript/lib/lib.es2022.d.ts","../node_modules/typescript/lib/lib.es2023.d.ts","../node_modules/typescript/lib/lib.esnext.d.ts","../node_modules/typescript/lib/lib.dom.d.ts","../node_modules/typescript/lib/lib.dom.iterable.d.ts","../node_modules/typescript/lib/lib.es2015.core.d.ts","../node_modules/typescript/lib/lib.es2015.collection.d.ts","../node_modules/typescript/lib/lib.es2015.generator.d.ts","../node_modules/typescript/lib/lib.es2015.iterable.d.ts","../node_modules/typescript/lib/lib.es2015.promise.d.ts","../node_modules/typescript/lib/lib.es2015.proxy.d.ts","../node_modules/typescript/lib/lib.es2015.reflect.d.ts","../node_modules/typescript/lib/lib.es2015.symbol.d.ts","../node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts","../node_modules/typescript/lib/lib.es2016.array.include.d.ts","../node_modules/typescript/lib/lib.es2016.intl.d.ts","../node_modules/typescript/lib/lib.es2017.date.d.ts","../node_modules/typescript/lib/lib.es2017.object.d.ts","../node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts","../node_modules/typescript/lib/lib.es2017.string.d.ts","../node_modules/typescript/lib/lib.es2017.intl.d.ts","../node_modules/typescript/lib/lib.es2017.typedarrays.d.ts","../node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts","../node_modules/typescript/lib/lib.es2018.asynciterable.d.ts","../node_modules/typescript/lib/lib.es2018.intl.d.ts","../node_modules/typescript/lib/lib.es2018.promise.d.ts","../node_modules/typescript/lib/lib.es2018.regexp.d.ts","../node_modules/typescript/lib/lib.es2019.array.d.ts","../node_modules/typescript/lib/lib.es2019.object.d.ts","../node_modules/typescript/lib/lib.es2019.string.d.ts","../node_modules/typescript/lib/lib.es2019.symbol.d.ts","../node_modules/typescript/lib/lib.es2019.intl.d.ts","../node_modules/typescript/lib/lib.es2020.bigint.d.ts","../node_modules/typescript/lib/lib.es2020.date.d.ts","../node_modules/typescript/lib/lib.es2020.promise.d.ts","../node_modules/typescript/lib/lib.es2020.sharedmemory.d.ts","../node_modules/typescript/lib/lib.es2020.string.d.ts","../node_modules/typescript/lib/lib.es2020.symbol.wellknown.d.ts","../node_modules/typescript/lib/lib.es2020.intl.d.ts","../node_modules/typescript/lib/lib.es2020.number.d.ts","../node_modules/typescript/lib/lib.es2021.promise.d.ts","../node_modules/typescript/lib/lib.es2021.string.d.ts","../node_modules/typescript/lib/lib.es2021.weakref.d.ts","../node_modules/typescript/lib/lib.es2021.intl.d.ts","../node_modules/typescript/lib/lib.es2022.array.d.ts","../node_modules/typescript/lib/lib.es2022.error.d.ts","../node_modules/typescript/lib/lib.es2022.intl.d.ts","../node_modules/typescript/lib/lib.es2022.object.d.ts","../node_modules/typescript/lib/lib.es2022.sharedmemory.d.ts","../node_modules/typescript/lib/lib.es2022.string.d.ts","../node_modules/typescript/lib/lib.es2022.regexp.d.ts","../node_modules/typescript/lib/lib.es2023.array.d.ts","../node_modules/typescript/lib/lib.es2023.collection.d.ts","../node_modules/typescript/lib/lib.esnext.collection.d.ts","../node_modules/typescript/lib/lib.esnext.intl.d.ts","../node_modules/typescript/lib/lib.esnext.disposable.d.ts","../node_modules/typescript/lib/lib.esnext.promise.d.ts","../node_modules/typescript/lib/lib.esnext.decorators.d.ts","../node_modules/typescript/lib/lib.esnext.object.d.ts","../node_modules/typescript/lib/lib.decorators.d.ts","../node_modules/typescript/lib/lib.decorators.legacy.d.ts","../src/constants.ts","../src/generators.ts","../src/utils.ts","../src/types.ts","../src/prng.ts","../src/index.ts"],"fileInfos":[{"version":"824cb491a40f7e8fdeb56f1df5edf91b23f3e3ee6b4cde84d4a99be32338faee","affectsGlobalScope":true},"45b7ab580deca34ae9729e97c13cfd999df04416a79116c3bfb483804f85ded4","3facaf05f0c5fc569c5649dd359892c98a85557e3e0c847964caeb67076f4d75","9a68c0c07ae2fa71b44384a839b7b8d81662a236d4b9ac30916718f7510b1b2d","5e1c4c362065a6b95ff952c0eab010f04dcd2c3494e813b493ecfd4fcb9fc0d8","68d73b4a11549f9c0b7d352d10e91e5dca8faa3322bfb77b661839c42b1ddec7","5efce4fc3c29ea84e8928f97adec086e3dc876365e0982cc8479a07954a3efd4","feecb1be483ed332fad555aff858affd90a48ab19ba7272ee084704eb7167569","5514e54f17d6d74ecefedc73c504eadffdeda79c7ea205cf9febead32d45c4bc","1c0cdb8dc619bc549c3e5020643e7cf7ae7940058e8c7e5aefa5871b6d86f44b","886e50ef125efb7878f744e86908884c0133e7a6d9d80013f421b0cd8fb2af94",{"version":"87d693a4920d794a73384b3c779cadcb8548ac6945aa7a925832fe2418c9527a","affectsGlobalScope":true},{"version":"76f838d5d49b65de83bc345c04aa54c62a3cfdb72a477dc0c0fce89a30596c30","affectsGlobalScope":true},{"version":"138fb588d26538783b78d1e3b2c2cc12d55840b97bf5e08bca7f7a174fbe2f17","affectsGlobalScope":true},{"version":"dc2df20b1bcdc8c2d34af4926e2c3ab15ffe1160a63e58b7e09833f616efff44","affectsGlobalScope":true},{"version":"4443e68b35f3332f753eacc66a04ac1d2053b8b035a0e0ac1d455392b5e243b3","affectsGlobalScope":true},{"version":"bc47685641087c015972a3f072480889f0d6c65515f12bd85222f49a98952ed7","affectsGlobalScope":true},{"version":"0dc1e7ceda9b8b9b455c3a2d67b0412feab00bd2f66656cd8850e8831b08b537","affectsGlobalScope":true},{"version":"ce691fb9e5c64efb9547083e4a34091bcbe5bdb41027e310ebba8f7d96a98671","affectsGlobalScope":true},{"version":"8d697a2a929a5fcb38b7a65594020fcef05ec1630804a33748829c5ff53640d0","affectsGlobalScope":true},{"version":"4ff2a353abf8a80ee399af572debb8faab2d33ad38c4b4474cff7f26e7653b8d","affectsGlobalScope":true},{"version":"93495ff27b8746f55d19fcbcdbaccc99fd95f19d057aed1bd2c0cafe1335fbf0","affectsGlobalScope":true},{"version":"6fc23bb8c3965964be8c597310a2878b53a0306edb71d4b5a4dfe760186bcc01","affectsGlobalScope":true},{"version":"ea011c76963fb15ef1cdd7ce6a6808b46322c527de2077b6cfdf23ae6f5f9ec7","affectsGlobalScope":true},{"version":"38f0219c9e23c915ef9790ab1d680440d95419ad264816fa15009a8851e79119","affectsGlobalScope":true},{"version":"bb42a7797d996412ecdc5b2787720de477103a0b2e53058569069a0e2bae6c7e","affectsGlobalScope":true},{"version":"4738f2420687fd85629c9efb470793bb753709c2379e5f85bc1815d875ceadcd","affectsGlobalScope":true},{"version":"2f11ff796926e0832f9ae148008138ad583bd181899ab7dd768a2666700b1893","affectsGlobalScope":true},{"version":"4de680d5bb41c17f7f68e0419412ca23c98d5749dcaaea1896172f06435891fc","affectsGlobalScope":true},{"version":"9fc46429fbe091ac5ad2608c657201eb68b6f1b8341bd6d670047d32ed0a88fa","affectsGlobalScope":true},{"version":"61c37c1de663cf4171e1192466e52c7a382afa58da01b1dc75058f032ddf0839","affectsGlobalScope":true},{"version":"b541a838a13f9234aba650a825393ffc2292dc0fc87681a5d81ef0c96d281e7a","affectsGlobalScope":true},{"version":"b20fe0eca9a4e405f1a5ae24a2b3290b37cf7f21eba6cbe4fc3fab979237d4f3","affectsGlobalScope":true},{"version":"811ec78f7fefcabbda4bfa93b3eb67d9ae166ef95f9bff989d964061cbf81a0c","affectsGlobalScope":true},{"version":"717937616a17072082152a2ef351cb51f98802fb4b2fdabd32399843875974ca","affectsGlobalScope":true},{"version":"d7e7d9b7b50e5f22c915b525acc5a49a7a6584cf8f62d0569e557c5cfc4b2ac2","affectsGlobalScope":true},{"version":"71c37f4c9543f31dfced6c7840e068c5a5aacb7b89111a4364b1d5276b852557","affectsGlobalScope":true},{"version":"576711e016cf4f1804676043e6a0a5414252560eb57de9faceee34d79798c850","affectsGlobalScope":true},{"version":"89c1b1281ba7b8a96efc676b11b264de7a8374c5ea1e6617f11880a13fc56dc6","affectsGlobalScope":true},{"version":"49ed889be54031e1044af0ad2c603d627b8bda8b50c1a68435fe85583901d072","affectsGlobalScope":true},{"version":"e93d098658ce4f0c8a0779e6cab91d0259efb88a318137f686ad76f8410ca270","affectsGlobalScope":true},{"version":"063600664504610fe3e99b717a1223f8b1900087fab0b4cad1496a114744f8df","affectsGlobalScope":true},{"version":"934019d7e3c81950f9a8426d093458b65d5aff2c7c1511233c0fd5b941e608ab","affectsGlobalScope":true},{"version":"bf14a426dbbf1022d11bd08d6b8e709a2e9d246f0c6c1032f3b2edb9a902adbe","affectsGlobalScope":true},{"version":"5e07ed3809d48205d5b985642a59f2eba47c402374a7cf8006b686f79efadcbd","affectsGlobalScope":true},{"version":"2b72d528b2e2fe3c57889ca7baef5e13a56c957b946906d03767c642f386bbc3","affectsGlobalScope":true},{"version":"8073890e29d2f46fdbc19b8d6d2eb9ea58db9a2052f8640af20baff9afbc8640","affectsGlobalScope":true},{"version":"368af93f74c9c932edd84c58883e736c9e3d53cec1fe24c0b0ff451f529ceab1","affectsGlobalScope":true},{"version":"af3dd424cf267428f30ccfc376f47a2c0114546b55c44d8c0f1d57d841e28d74","affectsGlobalScope":true},{"version":"995c005ab91a498455ea8dfb63aa9f83fa2ea793c3d8aa344be4a1678d06d399","affectsGlobalScope":true},{"version":"51e547984877a62227042850456de71a5c45e7fe86b7c975c6e68896c86fa23b","affectsGlobalScope":true},{"version":"956d27abdea9652e8368ce029bb1e0b9174e9678a273529f426df4b3d90abd60","affectsGlobalScope":true},{"version":"4fa6ed14e98aa80b91f61b9805c653ee82af3502dc21c9da5268d3857772ca05","affectsGlobalScope":true},{"version":"e6633e05da3ff36e6da2ec170d0d03ccf33de50ca4dc6f5aeecb572cedd162fb","affectsGlobalScope":true},{"version":"d8670852241d4c6e03f2b89d67497a4bbefe29ecaa5a444e2c11a9b05e6fccc6","affectsGlobalScope":true},{"version":"8444af78980e3b20b49324f4a16ba35024fef3ee069a0eb67616ea6ca821c47a","affectsGlobalScope":true},{"version":"caccc56c72713969e1cfe5c3d44e5bab151544d9d2b373d7dbe5a1e4166652be","affectsGlobalScope":true},{"version":"3287d9d085fbd618c3971944b65b4be57859f5415f495b33a6adc994edd2f004","affectsGlobalScope":true},{"version":"50d53ccd31f6667aff66e3d62adf948879a3a16f05d89882d1188084ee415bbc","affectsGlobalScope":true},{"version":"08a58483392df5fcc1db57d782e87734f77ae9eab42516028acbfe46f29a3ef7","affectsGlobalScope":true},{"version":"436aaf437562f276ec2ddbee2f2cdedac7664c1e4c1d2c36839ddd582eeb3d0a","affectsGlobalScope":true},{"version":"b1cb28af0c891c8c96b2d6b7be76bd394fddcfdb4709a20ba05a7c1605eea0f9","affectsGlobalScope":true},{"version":"13f6e6380c78e15e140243dc4be2fa546c287c6d61f4729bc2dd7cf449605471","affectsGlobalScope":true},{"version":"15b98a533864d324e5f57cd3cfc0579b231df58c1c0f6063ea0fcb13c3c74ff9","affectsGlobalScope":true},{"version":"ac77cb3e8c6d3565793eb90a8373ee8033146315a3dbead3bde8db5eaf5e5ec6","affectsGlobalScope":true},{"version":"d4b1d2c51d058fc21ec2629fff7a76249dec2e36e12960ea056e3ef89174080f","affectsGlobalScope":true},{"version":"2fef54945a13095fdb9b84f705f2b5994597640c46afeb2ce78352fab4cb3279","affectsGlobalScope":true},{"version":"33358442698bb565130f52ba79bfd3d4d484ac85fe33f3cb1759c54d18201393","affectsGlobalScope":true},{"version":"782dec38049b92d4e85c1585fbea5474a219c6984a35b004963b00beb1aab538","affectsGlobalScope":true},{"version":"616ab0bd2bbaf106ac22339078a358ee71f48f67c1ce6c3af6859b26d51a77a5","signature":"5d94ae30564d6c19b1321a2f4aa82f2e719fefb1928a04754dcbe4164f4ef5ff"},{"version":"9288dcc5a21b0fd8bdeb7a0432ff0dd9645b326b2c6fb6a32ed7d73502cad120","signature":"709e85ca16dd836d820b278ec307e9425f23dc9aa60a049ed312d12b66bb6069"},{"version":"8b97dffa88ef063ca82e610fd45159d839bd25c471b4d577e6c9726d865ab0ca","signature":"2f1af64d6ed029246747a1c222595701752389e1e314360cf403cab4d64d8df1"},{"version":"dac3e0680e3f4f20aa24da05e45d1d561aca3422debaef8c4c0eed9f21da2cdd","signature":"04eee05863b6e30ef98b265b28fb07f419a25295e6dfcea4b6cd16371d4c2bfa"},{"version":"d299e587560fe45b18b2f7ad5c713e72937745f4b844ec982c47244535fbbb61","signature":"499d75c68df08be3529a93f519dd15a59e89c5e1e3384157c79efc068e6d741c"},{"version":"4ad6c3c36a402735215d866c9a7d8a3247515d0997bc0c4d490f9bb9d9552919","signature":"af89e9999aa1cc41788c9ec6883fc71f145f88c6979739395eddf9b9a6313b44"}],"root":[[70,75]],"options":{"allowJs":true,"checkJs":true,"declaration":true,"module":99,"outDir":"./","skipLibCheck":true,"strict":true,"target":99},"fileIdsList":[[70,71,72,73,74],[70,71,72,73],[73]],"referencedMap":[[75,1],[74,2]],"exportedModulesMap":[[75,1],[74,3]],"semanticDiagnosticsPerFile":[68,69,12,13,15,14,2,16,17,18,19,20,21,22,23,3,24,4,25,29,26,27,28,30,31,32,5,33,34,35,36,6,40,37,38,39,41,7,42,47,48,43,44,45,46,8,52,49,50,51,53,9,54,55,56,59,57,58,60,61,10,1,62,11,66,64,63,67,65,70,71,75,74,73,72]},"version":"5.4.2"}
package/lib/types.d.ts CHANGED
@@ -1,8 +1,2 @@
1
- export declare enum AlgorithmName {
2
- jsf32 = "jsf32",
3
- mulberry32 = "mulberry32",
4
- sfc32 = "sfc32",
5
- splitmix32 = "splitmix32",
6
- xoshiro128ss = "xoshiro128**"
7
- }
8
- export type AlgorithmFunction = (...args: number[]) => number;
1
+ export type Seed = string | number;
2
+ export type Generator = (...hashes: number[]) => number;
package/lib/types.js CHANGED
@@ -1,8 +1 @@
1
- export var AlgorithmName;
2
- (function (AlgorithmName) {
3
- AlgorithmName["jsf32"] = "jsf32";
4
- AlgorithmName["mulberry32"] = "mulberry32";
5
- AlgorithmName["sfc32"] = "sfc32";
6
- AlgorithmName["splitmix32"] = "splitmix32";
7
- AlgorithmName["xoshiro128ss"] = "xoshiro128**";
8
- })(AlgorithmName || (AlgorithmName = {}));
1
+ export {};
package/lib/utils.d.ts ADDED
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Generate a random string that can be used as a seed
3
+ *
4
+ * @param {number} [length=64] Length of the generated seed string
5
+ * @returns {string} Generated random seed string
6
+ */
7
+ export declare function randomSeed(length?: number): string;
package/lib/utils.js ADDED
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Generate a random string that can be used as a seed
3
+ *
4
+ * @param {number} [length=64] Length of the generated seed string
5
+ * @returns {string} Generated random seed string
6
+ */
7
+ export function randomSeed(length = 64) {
8
+ let seed = "0x";
9
+ for (let i = length; i > 0; --i) {
10
+ seed += "0123456789abcdef"[~~(Math.random() * 16)];
11
+ }
12
+ return seed;
13
+ }
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "toosoon-prng",
3
- "version": "4.0.3",
3
+ "version": "4.1.0",
4
4
  "description": "This project provides PRNG functions for generating pseudo-random values using a seed-based approach and various algorithms",
5
5
  "type": "module",
6
6
  "engines": {
7
- "node": ">=16"
7
+ "node": ">=22"
8
8
  },
9
9
  "main": "./lib/index.js",
10
10
  "types": "./lib/index.d.ts",
package/.prettierrc DELETED
@@ -1,7 +0,0 @@
1
- {
2
- "semi": true,
3
- "singleQuote": true,
4
- "printWidth": 120,
5
- "trailingComma": "none",
6
- "endOfLine": "auto"
7
- }
package/tsconfig.json DELETED
@@ -1,28 +0,0 @@
1
- {
2
- "include": ["src"],
3
- "exclude": ["node_modules"],
4
- "compilerOptions": {
5
- "baseUrl": ".",
6
-
7
- "outDir": "lib",
8
-
9
- "target": "ESNext",
10
- "lib": ["ESNext", "DOM", "DOM.Iterable"],
11
- "skipLibCheck": true,
12
- "declaration": true,
13
- "incremental": true,
14
-
15
- /* Bundler mode */
16
- "module": "ESNext",
17
- "moduleResolution": "bundler",
18
- "moduleDetection": "force",
19
- "isolatedModules": true,
20
- "resolveJsonModule": true,
21
-
22
- /* Linting */
23
- "strict": true,
24
- "allowJs": true,
25
- "checkJs": true,
26
- "forceConsistentCasingInFileNames": true
27
- }
28
- }