@thi.ng/random 3.0.2 → 3.1.3
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 +71 -68
- package/README.md +1 -1
- 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/CHANGELOG.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
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.
|
|
6
|
+
## [3.1.3](https://github.com/thi-ng/umbrella/compare/@thi.ng/random@3.1.2...@thi.ng/random@3.1.3) (2021-11-03)
|
|
7
7
|
|
|
8
8
|
**Note:** Version bump only for package @thi.ng/random
|
|
9
9
|
|
|
@@ -11,9 +11,12 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
|
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
# [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)
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
|
|
17
|
+
### Features
|
|
18
|
+
|
|
19
|
+
* **random:** add pickRandom() ([0899aed](https://github.com/thi-ng/umbrella/commit/0899aed89fd691df4ddc5273995a579414f506d8))
|
|
17
20
|
|
|
18
21
|
|
|
19
22
|
|
|
@@ -48,129 +51,129 @@ Also:
|
|
|
48
51
|
|
|
49
52
|
|
|
50
53
|
|
|
51
|
-
## [2.4.4](https://github.com/thi-ng/umbrella/compare/@thi.ng/random@2.4.3...@thi.ng/random@2.4.4) (2021-08-04)
|
|
54
|
+
## [2.4.4](https://github.com/thi-ng/umbrella/compare/@thi.ng/random@2.4.3...@thi.ng/random@2.4.4) (2021-08-04)
|
|
52
55
|
|
|
53
|
-
### Bug Fixes
|
|
56
|
+
### Bug Fixes
|
|
54
57
|
|
|
55
|
-
- **random:** update weightedRandom() ([70afa70](https://github.com/thi-ng/umbrella/commit/70afa7097dfd21f85d947ab5f055d0c39589fd48))
|
|
58
|
+
- **random:** update weightedRandom() ([70afa70](https://github.com/thi-ng/umbrella/commit/70afa7097dfd21f85d947ab5f055d0c39589fd48))
|
|
56
59
|
|
|
57
|
-
# [2.4.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/random@2.3.7...@thi.ng/random@2.4.0) (2021-04-19)
|
|
60
|
+
# [2.4.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/random@2.3.7...@thi.ng/random@2.4.0) (2021-04-19)
|
|
58
61
|
|
|
59
|
-
### Bug Fixes
|
|
62
|
+
### Bug Fixes
|
|
60
63
|
|
|
61
|
-
- **random:** HOF issue w/ exponential() ([12586b9](https://github.com/thi-ng/umbrella/commit/12586b9eda66ce3d741402cc9b802c0369f64d88))
|
|
64
|
+
- **random:** HOF issue w/ exponential() ([12586b9](https://github.com/thi-ng/umbrella/commit/12586b9eda66ce3d741402cc9b802c0369f64d88))
|
|
62
65
|
|
|
63
|
-
### Features
|
|
66
|
+
### Features
|
|
64
67
|
|
|
65
|
-
- **random:** add uniqueValuesFrom/uniqueIndices() ([3b3b5d8](https://github.com/thi-ng/umbrella/commit/3b3b5d8d71d8c3019f84bae7a4791b12933720c4))
|
|
68
|
+
- **random:** add uniqueValuesFrom/uniqueIndices() ([3b3b5d8](https://github.com/thi-ng/umbrella/commit/3b3b5d8d71d8c3019f84bae7a4791b12933720c4))
|
|
66
69
|
|
|
67
|
-
## [2.3.1](https://github.com/thi-ng/umbrella/compare/@thi.ng/random@2.3.0...@thi.ng/random@2.3.1) (2021-02-24)
|
|
70
|
+
## [2.3.1](https://github.com/thi-ng/umbrella/compare/@thi.ng/random@2.3.0...@thi.ng/random@2.3.1) (2021-02-24)
|
|
68
71
|
|
|
69
|
-
### Bug Fixes
|
|
72
|
+
### Bug Fixes
|
|
70
73
|
|
|
71
|
-
- **random:** update weightedRandom() ([b1cf4d8](https://github.com/thi-ng/umbrella/commit/b1cf4d8feccac4b3468a2fb0fdee268306406d78))
|
|
74
|
+
- **random:** update weightedRandom() ([b1cf4d8](https://github.com/thi-ng/umbrella/commit/b1cf4d8feccac4b3468a2fb0fdee268306406d78))
|
|
72
75
|
|
|
73
|
-
# [2.3.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/random@2.2.0...@thi.ng/random@2.3.0) (2021-02-20)
|
|
76
|
+
# [2.3.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/random@2.2.0...@thi.ng/random@2.3.0) (2021-02-20)
|
|
74
77
|
|
|
75
|
-
### Features
|
|
78
|
+
### Features
|
|
76
79
|
|
|
77
|
-
- **random:** add coin()/fairCoin() ([ed66a64](https://github.com/thi-ng/umbrella/commit/ed66a64a7e5efb63b4bbab89bba5100d1aa7ec49))
|
|
80
|
+
- **random:** add coin()/fairCoin() ([ed66a64](https://github.com/thi-ng/umbrella/commit/ed66a64a7e5efb63b4bbab89bba5100d1aa7ec49))
|
|
78
81
|
|
|
79
|
-
# [2.2.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/random@2.1.5...@thi.ng/random@2.2.0) (2021-01-13)
|
|
82
|
+
# [2.2.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/random@2.1.5...@thi.ng/random@2.2.0) (2021-01-13)
|
|
80
83
|
|
|
81
|
-
### Bug Fixes
|
|
84
|
+
### Bug Fixes
|
|
82
85
|
|
|
83
|
-
- **random:** add opt start index arg for uuid() ([268ec3f](https://github.com/thi-ng/umbrella/commit/268ec3f47470184068fd66b5cc147d8c2e0e0ccb))
|
|
86
|
+
- **random:** add opt start index arg for uuid() ([268ec3f](https://github.com/thi-ng/umbrella/commit/268ec3f47470184068fd66b5cc147d8c2e0e0ccb))
|
|
84
87
|
|
|
85
|
-
### Features
|
|
88
|
+
### Features
|
|
86
89
|
|
|
87
|
-
- **random:** add CRYPTO IRandom impl ([94e69c1](https://github.com/thi-ng/umbrella/commit/94e69c1021ec67c63be78e0467bfc82be6cabc00))
|
|
88
|
-
- **random:** add opt start/end for randomBytes() ([4d095da](https://github.com/thi-ng/umbrella/commit/4d095da557b1f3ee9ce46778aeba25f0c6aa94f9))
|
|
90
|
+
- **random:** add CRYPTO IRandom impl ([94e69c1](https://github.com/thi-ng/umbrella/commit/94e69c1021ec67c63be78e0467bfc82be6cabc00))
|
|
91
|
+
- **random:** add opt start/end for randomBytes() ([4d095da](https://github.com/thi-ng/umbrella/commit/4d095da557b1f3ee9ce46778aeba25f0c6aa94f9))
|
|
89
92
|
|
|
90
|
-
### Performance Improvements
|
|
93
|
+
### Performance Improvements
|
|
91
94
|
|
|
92
|
-
- **random:** minor update weightedRandom() ([258fd7b](https://github.com/thi-ng/umbrella/commit/258fd7b25930c41025b7337b44c36e1f00924b47))
|
|
95
|
+
- **random:** minor update weightedRandom() ([258fd7b](https://github.com/thi-ng/umbrella/commit/258fd7b25930c41025b7337b44c36e1f00924b47))
|
|
93
96
|
|
|
94
|
-
## [2.1.1](https://github.com/thi-ng/umbrella/compare/@thi.ng/random@2.1.0...@thi.ng/random@2.1.1) (2020-11-26)
|
|
97
|
+
## [2.1.1](https://github.com/thi-ng/umbrella/compare/@thi.ng/random@2.1.0...@thi.ng/random@2.1.1) (2020-11-26)
|
|
95
98
|
|
|
96
|
-
### Bug Fixes
|
|
99
|
+
### Bug Fixes
|
|
97
100
|
|
|
98
|
-
- **random:** add missing subdir to pkg "files" ([916dbe7](https://github.com/thi-ng/umbrella/commit/916dbe7eb12815215b3905ea6ad924b7d397264c))
|
|
101
|
+
- **random:** add missing subdir to pkg "files" ([916dbe7](https://github.com/thi-ng/umbrella/commit/916dbe7eb12815215b3905ea6ad924b7d397264c))
|
|
99
102
|
|
|
100
|
-
# [2.1.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/random@2.0.2...@thi.ng/random@2.1.0) (2020-11-24)
|
|
103
|
+
# [2.1.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/random@2.0.2...@thi.ng/random@2.1.0) (2020-11-24)
|
|
101
104
|
|
|
102
|
-
### Features
|
|
105
|
+
### Features
|
|
103
106
|
|
|
104
|
-
- **random:** add distribution HOFs, move gaussian() ([9328821](https://github.com/thi-ng/umbrella/commit/9328821b20e9534c4c66c353d36dfd7dbb5edda6))
|
|
105
|
-
- **random:** add randomBytesFrom(), update UUID fns ([b31c872](https://github.com/thi-ng/umbrella/commit/b31c872cb67708510d68d6b2e2260cba843ee86d))
|
|
107
|
+
- **random:** add distribution HOFs, move gaussian() ([9328821](https://github.com/thi-ng/umbrella/commit/9328821b20e9534c4c66c353d36dfd7dbb5edda6))
|
|
108
|
+
- **random:** add randomBytesFrom(), update UUID fns ([b31c872](https://github.com/thi-ng/umbrella/commit/b31c872cb67708510d68d6b2e2260cba843ee86d))
|
|
106
109
|
|
|
107
|
-
# [2.0.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/random@1.4.17...@thi.ng/random@2.0.0) (2020-08-28)
|
|
110
|
+
# [2.0.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/random@1.4.17...@thi.ng/random@2.0.0) (2020-08-28)
|
|
108
111
|
|
|
109
|
-
### Bug Fixes
|
|
112
|
+
### Bug Fixes
|
|
110
113
|
|
|
111
|
-
- **random:** off-by-one error in SYSTEM.int() ([ca0492d](https://github.com/thi-ng/umbrella/commit/ca0492d2f5f867c8945c279f60cf908037df1385))
|
|
114
|
+
- **random:** off-by-one error in SYSTEM.int() ([ca0492d](https://github.com/thi-ng/umbrella/commit/ca0492d2f5f867c8945c279f60cf908037df1385))
|
|
112
115
|
|
|
113
|
-
### Features
|
|
116
|
+
### Features
|
|
114
117
|
|
|
115
|
-
- **random:** add INorm, extract gaussianCLT() ([c687598](https://github.com/thi-ng/umbrella/commit/c687598f87283a77c109d6b378b1907349eab760))
|
|
118
|
+
- **random:** add INorm, extract gaussianCLT() ([c687598](https://github.com/thi-ng/umbrella/commit/c687598f87283a77c109d6b378b1907349eab760))
|
|
116
119
|
|
|
117
|
-
### BREAKING CHANGES
|
|
120
|
+
### BREAKING CHANGES
|
|
118
121
|
|
|
119
|
-
- **random:** remove gaussian() from IRandom, extract as standalone gaussianCLT()
|
|
120
|
-
- update gaussianCLT() default args to be more meaningful
|
|
122
|
+
- **random:** remove gaussian() from IRandom, extract as standalone gaussianCLT()
|
|
123
|
+
- update gaussianCLT() default args to be more meaningful
|
|
121
124
|
|
|
122
|
-
# [1.4.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/random@1.3.2...@thi.ng/random@1.4.0) (2020-03-01)
|
|
125
|
+
# [1.4.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/random@1.3.2...@thi.ng/random@1.4.0) (2020-03-01)
|
|
123
126
|
|
|
124
|
-
### Bug Fixes
|
|
127
|
+
### Bug Fixes
|
|
125
128
|
|
|
126
|
-
- **random:** use correct 160bit default seed for XorWow ([38d511b](https://github.com/thi-ng/umbrella/commit/38d511bc2e2c0bf00101e0b9db50cdb371445425))
|
|
129
|
+
- **random:** use correct 160bit default seed for XorWow ([38d511b](https://github.com/thi-ng/umbrella/commit/38d511bc2e2c0bf00101e0b9db50cdb371445425))
|
|
127
130
|
|
|
128
|
-
### Features
|
|
131
|
+
### Features
|
|
129
132
|
|
|
130
|
-
- **random:** add Xoshiro128, refactor default seeds ([b535628](https://github.com/thi-ng/umbrella/commit/b535628c879b133d121307695a2a138dac70f008))
|
|
133
|
+
- **random:** add Xoshiro128, refactor default seeds ([b535628](https://github.com/thi-ng/umbrella/commit/b535628c879b133d121307695a2a138dac70f008))
|
|
131
134
|
|
|
132
|
-
# [1.3.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/random@1.2.0...@thi.ng/random@1.3.0) (2020-02-25)
|
|
135
|
+
# [1.3.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/random@1.2.0...@thi.ng/random@1.3.0) (2020-02-25)
|
|
133
136
|
|
|
134
|
-
### Features
|
|
137
|
+
### Features
|
|
135
138
|
|
|
136
|
-
- **random:** add uuidv4Bytes() ([e9ea10f](https://github.com/thi-ng/umbrella/commit/e9ea10f5e6b2415863e1a552207758aa3a47c9cf))
|
|
139
|
+
- **random:** add uuidv4Bytes() ([e9ea10f](https://github.com/thi-ng/umbrella/commit/e9ea10f5e6b2415863e1a552207758aa3a47c9cf))
|
|
137
140
|
|
|
138
|
-
# [1.2.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/random@1.1.15...@thi.ng/random@1.2.0) (2020-01-26)
|
|
141
|
+
# [1.2.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/random@1.1.15...@thi.ng/random@1.2.0) (2020-01-26)
|
|
139
142
|
|
|
140
|
-
### Features
|
|
143
|
+
### Features
|
|
141
144
|
|
|
142
|
-
- **random:** add randomBytes() wrapper ([c536bcd](https://github.com/thi-ng/umbrella/commit/c536bcd83c766414e349f6b82494ace9888ac2ba))
|
|
145
|
+
- **random:** add randomBytes() wrapper ([c536bcd](https://github.com/thi-ng/umbrella/commit/c536bcd83c766414e349f6b82494ace9888ac2ba))
|
|
143
146
|
|
|
144
|
-
## [1.1.15](https://github.com/thi-ng/umbrella/compare/@thi.ng/random@1.1.14...@thi.ng/random@1.1.15) (2020-01-24)
|
|
147
|
+
## [1.1.15](https://github.com/thi-ng/umbrella/compare/@thi.ng/random@1.1.14...@thi.ng/random@1.1.15) (2020-01-24)
|
|
145
148
|
|
|
146
|
-
### Performance Improvements
|
|
149
|
+
### Performance Improvements
|
|
147
150
|
|
|
148
|
-
- **random:** minor update ARandom.norm() ([babbbaa](https://github.com/thi-ng/umbrella/commit/babbbaa12b5be09415f420e7559fa5c8bb76f802))
|
|
151
|
+
- **random:** minor update ARandom.norm() ([babbbaa](https://github.com/thi-ng/umbrella/commit/babbbaa12b5be09415f420e7559fa5c8bb76f802))
|
|
149
152
|
|
|
150
|
-
# [1.1.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/random@1.0.2...@thi.ng/random@1.1.0) (2019-02-15)
|
|
153
|
+
# [1.1.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/random@1.0.2...@thi.ng/random@1.1.0) (2019-02-15)
|
|
151
154
|
|
|
152
|
-
### Bug Fixes
|
|
155
|
+
### Bug Fixes
|
|
153
156
|
|
|
154
|
-
- **random:** add opt scale arg to IRandom.float() ([5a7e448](https://github.com/thi-ng/umbrella/commit/5a7e448))
|
|
157
|
+
- **random:** add opt scale arg to IRandom.float() ([5a7e448](https://github.com/thi-ng/umbrella/commit/5a7e448))
|
|
155
158
|
|
|
156
|
-
### Features
|
|
159
|
+
### Features
|
|
157
160
|
|
|
158
|
-
- **random:** add randomID() & weightedRandom() ([f719724](https://github.com/thi-ng/umbrella/commit/f719724))
|
|
161
|
+
- **random:** add randomID() & weightedRandom() ([f719724](https://github.com/thi-ng/umbrella/commit/f719724))
|
|
159
162
|
|
|
160
|
-
# [1.0.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/random@0.1.1...@thi.ng/random@1.0.0) (2019-01-21)
|
|
163
|
+
# [1.0.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/random@0.1.1...@thi.ng/random@1.0.0) (2019-01-21)
|
|
161
164
|
|
|
162
|
-
### Build System
|
|
165
|
+
### Build System
|
|
163
166
|
|
|
164
|
-
- update package build scripts & outputs, imports in ~50 packages ([b54b703](https://github.com/thi-ng/umbrella/commit/b54b703))
|
|
167
|
+
- update package build scripts & outputs, imports in ~50 packages ([b54b703](https://github.com/thi-ng/umbrella/commit/b54b703))
|
|
165
168
|
|
|
166
|
-
### BREAKING CHANGES
|
|
169
|
+
### BREAKING CHANGES
|
|
167
170
|
|
|
168
|
-
- enabled multi-outputs (ES6 modules, CJS, UMD)
|
|
169
|
-
- build scripts now first build ES6 modules in package root, then call `scripts/bundle-module` to build minified CJS & UMD bundles in `/lib`
|
|
170
|
-
- all imports MUST be updated to only refer to package level (not individual files anymore). tree shaking in user land will get rid of all unused imported symbols.
|
|
171
|
+
- enabled multi-outputs (ES6 modules, CJS, UMD)
|
|
172
|
+
- build scripts now first build ES6 modules in package root, then call `scripts/bundle-module` to build minified CJS & UMD bundles in `/lib`
|
|
173
|
+
- all imports MUST be updated to only refer to package level (not individual files anymore). tree shaking in user land will get rid of all unused imported symbols.
|
|
171
174
|
|
|
172
|
-
# 0.1.0 (2018-11-24)
|
|
175
|
+
# 0.1.0 (2018-11-24)
|
|
173
176
|
|
|
174
|
-
### Features
|
|
177
|
+
### Features
|
|
175
178
|
|
|
176
179
|
- **random:** re-import, extend & refactor random package (MBP2010) ([4aea85d](https://github.com/thi-ng/umbrella/commit/4aea85d))
|
package/README.md
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.3",
|
|
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.1.0",
|
|
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": "852cd2450617c86d15d18477dc634f17f04202eb"
|
|
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];
|