@xtia/alea-rc 0.0.10 → 0.0.11

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
@@ -7,7 +7,7 @@ Alea is a utility wrapper for turning random numbers into useful values. Give it
7
7
  * Fully typed
8
8
  * Crypto-safe and seeded algorithms out-of-the-box
9
9
  * No dependencies
10
- * ~2.6kb minified core
10
+ * ~2.4kb minified core
11
11
  * Ranged int, array shuffling, dice roll, weighted sampling, recursive template phrase generation, UUID, bytes and many more
12
12
 
13
13
  ## Brief:
@@ -9,12 +9,6 @@ export declare class Alea {
9
9
  * @param next Source RNG - a function that returns a value >= 0 and < 1
10
10
  */
11
11
  constructor(next: RandomFunction);
12
- /**
13
- * Generate a series of normalised random values
14
- * @param count
15
- * @returns Random values
16
- */
17
- batch(count: number): number[];
18
12
  /**
19
13
  * Pick a random item from an array
20
14
  * @param items
@@ -109,20 +103,6 @@ export declare class Alea {
109
103
  * @returns Gaussian normal pair
110
104
  */
111
105
  normal(mean?: number, deviation?: number): [number, number];
112
- /**
113
- * Get a random integer value between `min` and `max`, inclusive.
114
- * @param min Minimum value, **inclusive**
115
- * @param max Maximum value, **inclusive**
116
- * @returns Random int value
117
- */
118
- int(min: number, max: number): number;
119
- /**
120
- * Roll dice
121
- * @param count Number of dice to roll (default 1)
122
- * @param sides Number of sides per die (default 6)
123
- * @returns Dice result
124
- */
125
- roll(count?: number, sides?: number): number;
126
106
  /**
127
107
  * Generate a random UUID (version 4)
128
108
  *
package/internal/alea.js CHANGED
@@ -5,17 +5,6 @@ export class Alea {
5
5
  constructor(next) {
6
6
  this.next = next;
7
7
  }
8
- /**
9
- * Generate a series of normalised random values
10
- * @param count
11
- * @returns Random values
12
- */
13
- batch(count) {
14
- if (!Number.isInteger(count) || count < 0) {
15
- throw new RangeError("count must be a non-negative integer");
16
- }
17
- return Array.from({ length: count }, () => this.next());
18
- }
19
8
  sample(items, count) {
20
9
  if (count === undefined) {
21
10
  if (items.length === 0)
@@ -157,10 +146,10 @@ export class Alea {
157
146
  const words = Math.floor(len / 4);
158
147
  const view = new DataView(byteArray.buffer, byteArray.byteOffset, byteArray.byteLength);
159
148
  for (let i = 0; i < words; i++) {
160
- view.setUint32(i * 4, this.int(0, 0xffffffff));
149
+ view.setUint32(i * 4, this.between(0, 0x100000000) >>> 0);
161
150
  }
162
151
  for (let i = words * 4; i < len; i++) {
163
- byteArray[i] = this.int(0, 255);
152
+ byteArray[i] = this.between(0, 256) | 0;
164
153
  }
165
154
  return result;
166
155
  }
@@ -199,28 +188,6 @@ export class Alea {
199
188
  mean + z1 * deviation
200
189
  ];
201
190
  }
202
- /**
203
- * Get a random integer value between `min` and `max`, inclusive.
204
- * @param min Minimum value, **inclusive**
205
- * @param max Maximum value, **inclusive**
206
- * @returns Random int value
207
- */
208
- int(min, max) {
209
- return Math.floor(this.between(min, max + 1));
210
- }
211
- /**
212
- * Roll dice
213
- * @param count Number of dice to roll (default 1)
214
- * @param sides Number of sides per die (default 6)
215
- * @returns Dice result
216
- */
217
- roll(count = 1, sides = 6) {
218
- let total = 0;
219
- for (let i = 0; i < count; i++) {
220
- total += this.int(1, sides);
221
- }
222
- return total;
223
- }
224
191
  /**
225
192
  * Generate a random UUID (version 4)
226
193
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xtia/alea-rc",
3
- "version": "0.0.10",
3
+ "version": "0.0.11",
4
4
  "description": "RNG utilities",
5
5
  "repository": {
6
6
  "url": "https://github.com/tiadrop/alea",