@thi.ng/random 3.0.1 → 3.1.2
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/CHANGELOG.md +43 -0
- package/README.md +1 -1
- package/crypto.js +0 -3
- package/index.d.ts +13 -12
- package/index.js +13 -12
- package/package.json +10 -7
- package/pick-random.d.ts +12 -0
- package/pick-random.js +12 -0
- package/smush32.js +0 -1
- package/xorshift128.js +0 -1
- package/xorwow.js +0 -1
- package/xoshiro128.js +0 -1
- package/xsadd.js +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,49 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [3.1.2](https://github.com/thi-ng/umbrella/compare/@thi.ng/random@3.1.1...@thi.ng/random@3.1.2) (2021-10-28)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @thi.ng/random
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
## [3.1.1](https://github.com/thi-ng/umbrella/compare/@thi.ng/random@3.1.0...@thi.ng/random@3.1.1) (2021-10-28)
|
|
15
|
+
|
|
16
|
+
**Note:** Version bump only for package @thi.ng/random
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
# [3.1.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/random@3.0.3...@thi.ng/random@3.1.0) (2021-10-25)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
### Features
|
|
26
|
+
|
|
27
|
+
* **random:** add pickRandom() ([0899aed](https://github.com/thi-ng/umbrella/commit/0899aed89fd691df4ddc5273995a579414f506d8))
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
## [3.0.3](https://github.com/thi-ng/umbrella/compare/@thi.ng/random@3.0.2...@thi.ng/random@3.0.3) (2021-10-15)
|
|
34
|
+
|
|
35
|
+
**Note:** Version bump only for package @thi.ng/random
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
## [3.0.2](https://github.com/thi-ng/umbrella/compare/@thi.ng/random@3.0.1...@thi.ng/random@3.0.2) (2021-10-15)
|
|
42
|
+
|
|
43
|
+
**Note:** Version bump only for package @thi.ng/random
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
|
|
6
49
|
## [3.0.1](https://github.com/thi-ng/umbrella/compare/@thi.ng/random@3.0.0...@thi.ng/random@3.0.1) (2021-10-13)
|
|
7
50
|
|
|
8
51
|
**Note:** Version bump only for package @thi.ng/random
|
package/README.md
CHANGED
package/crypto.js
CHANGED
package/index.d.ts
CHANGED
|
@@ -1,21 +1,22 @@
|
|
|
1
1
|
export * from "./api.js";
|
|
2
2
|
export * from "./arandom.js";
|
|
3
|
-
export * from "./crypto.js";
|
|
4
|
-
export * from "./smush32.js";
|
|
5
|
-
export * from "./system.js";
|
|
6
|
-
export * from "./xoshiro128.js";
|
|
7
|
-
export * from "./xorshift128.js";
|
|
8
|
-
export * from "./xorwow.js";
|
|
9
|
-
export * from "./xsadd.js";
|
|
10
3
|
export * from "./coin.js";
|
|
11
|
-
export * from "./
|
|
12
|
-
export * from "./random-id.js";
|
|
13
|
-
export * from "./unique-indices.js";
|
|
14
|
-
export * from "./uuid.js";
|
|
15
|
-
export * from "./weighted-random.js";
|
|
4
|
+
export * from "./crypto.js";
|
|
16
5
|
export * from "./distributions/exponential.js";
|
|
17
6
|
export * from "./distributions/gaussian.js";
|
|
18
7
|
export * from "./distributions/geometric.js";
|
|
19
8
|
export * from "./distributions/normal.js";
|
|
20
9
|
export * from "./distributions/uniform.js";
|
|
10
|
+
export * from "./pick-random.js";
|
|
11
|
+
export * from "./random-bytes.js";
|
|
12
|
+
export * from "./random-id.js";
|
|
13
|
+
export * from "./smush32.js";
|
|
14
|
+
export * from "./system.js";
|
|
15
|
+
export * from "./unique-indices.js";
|
|
16
|
+
export * from "./uuid.js";
|
|
17
|
+
export * from "./weighted-random.js";
|
|
18
|
+
export * from "./xorshift128.js";
|
|
19
|
+
export * from "./xorwow.js";
|
|
20
|
+
export * from "./xoshiro128.js";
|
|
21
|
+
export * from "./xsadd.js";
|
|
21
22
|
//# sourceMappingURL=index.d.ts.map
|
package/index.js
CHANGED
|
@@ -1,20 +1,21 @@
|
|
|
1
1
|
export * from "./api.js";
|
|
2
2
|
export * from "./arandom.js";
|
|
3
|
-
export * from "./crypto.js";
|
|
4
|
-
export * from "./smush32.js";
|
|
5
|
-
export * from "./system.js";
|
|
6
|
-
export * from "./xoshiro128.js";
|
|
7
|
-
export * from "./xorshift128.js";
|
|
8
|
-
export * from "./xorwow.js";
|
|
9
|
-
export * from "./xsadd.js";
|
|
10
3
|
export * from "./coin.js";
|
|
11
|
-
export * from "./
|
|
12
|
-
export * from "./random-id.js";
|
|
13
|
-
export * from "./unique-indices.js";
|
|
14
|
-
export * from "./uuid.js";
|
|
15
|
-
export * from "./weighted-random.js";
|
|
4
|
+
export * from "./crypto.js";
|
|
16
5
|
export * from "./distributions/exponential.js";
|
|
17
6
|
export * from "./distributions/gaussian.js";
|
|
18
7
|
export * from "./distributions/geometric.js";
|
|
19
8
|
export * from "./distributions/normal.js";
|
|
20
9
|
export * from "./distributions/uniform.js";
|
|
10
|
+
export * from "./pick-random.js";
|
|
11
|
+
export * from "./random-bytes.js";
|
|
12
|
+
export * from "./random-id.js";
|
|
13
|
+
export * from "./smush32.js";
|
|
14
|
+
export * from "./system.js";
|
|
15
|
+
export * from "./unique-indices.js";
|
|
16
|
+
export * from "./uuid.js";
|
|
17
|
+
export * from "./weighted-random.js";
|
|
18
|
+
export * from "./xorshift128.js";
|
|
19
|
+
export * from "./xorwow.js";
|
|
20
|
+
export * from "./xoshiro128.js";
|
|
21
|
+
export * from "./xsadd.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thi.ng/random",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.1.2",
|
|
4
4
|
"description": "Pseudo-random number generators w/ unified API, distributions, weighted choices, ID generation",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "./index.js",
|
|
@@ -34,13 +34,13 @@
|
|
|
34
34
|
"test": "testament test"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@thi.ng/api": "^8.0.
|
|
38
|
-
"@thi.ng/checks": "^3.0.
|
|
39
|
-
"@thi.ng/errors": "^2.0.
|
|
40
|
-
"@thi.ng/hex": "^2.0.
|
|
37
|
+
"@thi.ng/api": "^8.0.6",
|
|
38
|
+
"@thi.ng/checks": "^3.0.6",
|
|
39
|
+
"@thi.ng/errors": "^2.0.6",
|
|
40
|
+
"@thi.ng/hex": "^2.0.6"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
|
-
"@thi.ng/testament": "^0.1.
|
|
43
|
+
"@thi.ng/testament": "^0.1.6"
|
|
44
44
|
},
|
|
45
45
|
"keywords": [
|
|
46
46
|
"binary",
|
|
@@ -105,6 +105,9 @@
|
|
|
105
105
|
"./distributions/uniform": {
|
|
106
106
|
"import": "./distributions/uniform.js"
|
|
107
107
|
},
|
|
108
|
+
"./pick-random": {
|
|
109
|
+
"import": "./pick-random.js"
|
|
110
|
+
},
|
|
108
111
|
"./random-bytes": {
|
|
109
112
|
"import": "./random-bytes.js"
|
|
110
113
|
},
|
|
@@ -145,5 +148,5 @@
|
|
|
145
148
|
"ksuid"
|
|
146
149
|
]
|
|
147
150
|
},
|
|
148
|
-
"gitHead": "
|
|
151
|
+
"gitHead": "c17a556ad25f6882dfa8f806a1d9e8ed7ac7cd71"
|
|
149
152
|
}
|
package/pick-random.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns a random element from `src` using given {@link IRandom} instance
|
|
3
|
+
* (default: {@link SYSTEM}). The index selection will be constrained to the
|
|
4
|
+
* `[start,end)` interval (default: entire array).
|
|
5
|
+
*
|
|
6
|
+
* @param src
|
|
7
|
+
* @param rnd
|
|
8
|
+
* @param start
|
|
9
|
+
* @param end
|
|
10
|
+
*/
|
|
11
|
+
export declare const pickRandom: <T>(src: ArrayLike<T>, rnd?: import("./system.js").SystemRandom, start?: number, end?: number) => T;
|
|
12
|
+
//# sourceMappingURL=pick-random.d.ts.map
|
package/pick-random.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { SYSTEM } from "./system.js";
|
|
2
|
+
/**
|
|
3
|
+
* Returns a random element from `src` using given {@link IRandom} instance
|
|
4
|
+
* (default: {@link SYSTEM}). The index selection will be constrained to the
|
|
5
|
+
* `[start,end)` interval (default: entire array).
|
|
6
|
+
*
|
|
7
|
+
* @param src
|
|
8
|
+
* @param rnd
|
|
9
|
+
* @param start
|
|
10
|
+
* @param end
|
|
11
|
+
*/
|
|
12
|
+
export const pickRandom = (src, rnd = SYSTEM, start = 0, end = src.length) => src[rnd.minmax(start, end) | 0];
|
package/smush32.js
CHANGED
|
@@ -8,7 +8,6 @@ import { DEFAULT_SEED_32 } from "./constants.js";
|
|
|
8
8
|
* - https://gist.github.com/voidqk/d112165a26b45244a65298933c0349a4
|
|
9
9
|
*/
|
|
10
10
|
export class Smush32 extends ARandom {
|
|
11
|
-
buffer;
|
|
12
11
|
constructor(seed = DEFAULT_SEED_32) {
|
|
13
12
|
super();
|
|
14
13
|
this.buffer = new Uint32Array([seed, 0]);
|
package/xorshift128.js
CHANGED
package/xorwow.js
CHANGED
package/xoshiro128.js
CHANGED
package/xsadd.js
CHANGED
|
@@ -5,7 +5,6 @@ import { DEFAULT_SEED_32 } from "./constants.js";
|
|
|
5
5
|
* Reference: https://github.com/MersenneTwister-Lab/XSadd/blob/develop/xsadd.h
|
|
6
6
|
*/
|
|
7
7
|
export class XsAdd extends ARandom {
|
|
8
|
-
buffer;
|
|
9
8
|
constructor(seed = DEFAULT_SEED_32) {
|
|
10
9
|
super();
|
|
11
10
|
this.buffer = new Uint32Array(4);
|