@thi.ng/random 3.1.2 → 3.2.1
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 +150 -115
- package/README.md +1 -1
- package/package.json +156 -151
- package/random-id.js +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,211 +1,246 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
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
|
-
|
|
3
|
+
- **Last updated**: 2021-11-19T07:59:51Z
|
|
4
|
+
- **Generator**: [thi.ng/monopub](https://thi.ng/monopub)
|
|
31
5
|
|
|
6
|
+
All notable changes to this project will be documented in this file.
|
|
7
|
+
See [Conventional Commits](https://conventionalcommits.org/) for commit guidelines.
|
|
32
8
|
|
|
33
|
-
|
|
9
|
+
**Note:** Unlisted _patch_ versions only involve non-code or otherwise excluded changes
|
|
10
|
+
and/or version bumps of transitive dependencies.
|
|
34
11
|
|
|
35
|
-
|
|
12
|
+
## [3.2.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/random@3.2.0) (2021-11-17)
|
|
36
13
|
|
|
14
|
+
#### 🚀 Features
|
|
37
15
|
|
|
16
|
+
- Using workspaces for local tools ([bf7a404](https://github.com/thi-ng/umbrella/commit/bf7a404))
|
|
17
|
+
Improving the overall build ergonomics
|
|
18
|
+
- introduced a tools workspaces
|
|
19
|
+
- imported it in all needed packages/examples
|
|
20
|
+
- inclusive project root
|
|
38
21
|
|
|
22
|
+
#### ♻️ Refactoring
|
|
39
23
|
|
|
24
|
+
- testrunner to binary ([4ebbbb2](https://github.com/thi-ng/umbrella/commit/4ebbbb2))
|
|
25
|
+
this commit reverts (partly) changes made in:
|
|
26
|
+
ef346d7a8753590dc9094108a3d861a8dbd5dd2c
|
|
27
|
+
overall purpose is better testament ergonomics:
|
|
28
|
+
instead of having to pass NODE_OPTIONS with every invocation
|
|
29
|
+
having a binary to handle this for us.
|
|
40
30
|
|
|
41
|
-
|
|
31
|
+
### [3.1.4](https://github.com/thi-ng/umbrella/tree/@thi.ng/random@3.1.4) (2021-11-10)
|
|
42
32
|
|
|
43
|
-
|
|
33
|
+
#### ♻️ Refactoring
|
|
44
34
|
|
|
35
|
+
- update all countdown loops ([a5f374b](https://github.com/thi-ng/umbrella/commit/a5f374b))
|
|
45
36
|
|
|
37
|
+
## [3.1.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/random@3.1.0) (2021-10-25)
|
|
46
38
|
|
|
39
|
+
#### 🚀 Features
|
|
47
40
|
|
|
41
|
+
- add pickRandom() ([0899aed](https://github.com/thi-ng/umbrella/commit/0899aed))
|
|
48
42
|
|
|
49
|
-
|
|
43
|
+
### [3.0.1](https://github.com/thi-ng/umbrella/tree/@thi.ng/random@3.0.1) (2021-10-13)
|
|
50
44
|
|
|
51
|
-
|
|
45
|
+
#### ♻️ Refactoring
|
|
52
46
|
|
|
47
|
+
- update imports in all tests/pkgs ([effd591](https://github.com/thi-ng/umbrella/commit/effd591))
|
|
48
|
+
- update imports in all pkgs ([5fa2b6f](https://github.com/thi-ng/umbrella/commit/5fa2b6f))
|
|
49
|
+
- add .js suffix for all relative imports
|
|
53
50
|
|
|
51
|
+
# [3.0.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/random@3.0.0) (2021-10-12)
|
|
54
52
|
|
|
53
|
+
#### 🛑 Breaking changes
|
|
55
54
|
|
|
55
|
+
- major update of ALL pkgs (export maps, ESM only) ([0d1d6ea](https://github.com/thi-ng/umbrella/commit/0d1d6ea))
|
|
56
|
+
- BREAKING CHANGE: discontinue CommonJS & UMD versions
|
|
57
|
+
- only ESM modules will be published from now on
|
|
58
|
+
- CJS obsolete due to ESM support in recent versions of node:
|
|
59
|
+
- i.e. launch NodeJS via:
|
|
60
|
+
- `node --experimental-specifier-resolution=node --experimental-repl-await`
|
|
61
|
+
- in the node REPL use `await import(...)` instead of `require()`
|
|
62
|
+
- UMD obsolete due to widespread browser support for ESM
|
|
63
|
+
Also:
|
|
64
|
+
- normalize/restructure/reorg all package.json files
|
|
65
|
+
- cleanup all build scripts, remove obsolete
|
|
66
|
+
- switch from mocha to [@thi.ng/testament](https://github.com/thi-ng/umbrella/tree/main/packages/testament) for all tests
|
|
56
67
|
|
|
57
|
-
|
|
68
|
+
#### ♻️ Refactoring
|
|
58
69
|
|
|
70
|
+
- update deps & imports in various pkgs ([e1cf29e](https://github.com/thi-ng/umbrella/commit/e1cf29e))
|
|
71
|
+
- largely related to recent updates/restructuring of these packages:
|
|
72
|
+
- api
|
|
73
|
+
- defmulti
|
|
74
|
+
- errors
|
|
75
|
+
- logger
|
|
76
|
+
- update imports ([138571a](https://github.com/thi-ng/umbrella/commit/138571a))
|
|
77
|
+
- update all test stubs ([f2d6d53](https://github.com/thi-ng/umbrella/commit/f2d6d53))
|
|
78
|
+
- update all tests in _all_ pkgs ([8b582bc](https://github.com/thi-ng/umbrella/commit/8b582bc))
|
|
79
|
+
- update all to use [@thi.ng/testament](https://github.com/thi-ng/umbrella/tree/main/packages/testament)
|
|
59
80
|
|
|
60
|
-
###
|
|
81
|
+
### [2.4.4](https://github.com/thi-ng/umbrella/tree/@thi.ng/random@2.4.4) (2021-08-04)
|
|
61
82
|
|
|
62
|
-
|
|
83
|
+
#### 🩹 Bug fixes
|
|
63
84
|
|
|
85
|
+
- update weightedRandom() ([70afa70](https://github.com/thi-ng/umbrella/commit/70afa70))
|
|
86
|
+
- assume missing weights as zero
|
|
64
87
|
|
|
65
|
-
|
|
88
|
+
## [2.4.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/random@2.4.0) (2021-04-19)
|
|
66
89
|
|
|
67
|
-
|
|
90
|
+
#### 🚀 Features
|
|
68
91
|
|
|
69
|
-
-
|
|
70
|
-
- CJS obsolete due to ESM support in recent versions of node:
|
|
71
|
-
- i.e. launch NodeJS via:
|
|
72
|
-
- `node --experimental-specifier-resolution=node --experimental-repl-await`
|
|
73
|
-
- in the node REPL use `await import(...)` instead of `require()`
|
|
74
|
-
- UMD obsolete due to widespread browser support for ESM
|
|
92
|
+
- add uniqueValuesFrom/uniqueIndices() ([3b3b5d8](https://github.com/thi-ng/umbrella/commit/3b3b5d8))
|
|
75
93
|
|
|
76
|
-
|
|
77
|
-
- normalize/restructure/reorg all package.json files
|
|
78
|
-
- cleanup all build scripts, remove obsolete
|
|
79
|
-
- switch from mocha to @thi.ng/testament for all tests
|
|
94
|
+
#### 🩹 Bug fixes
|
|
80
95
|
|
|
96
|
+
- HOF issue w/ exponential() ([12586b9](https://github.com/thi-ng/umbrella/commit/12586b9))
|
|
81
97
|
|
|
98
|
+
#### ♻️ Refactoring
|
|
82
99
|
|
|
100
|
+
- minor updates weightedRandom() ([c6741bc](https://github.com/thi-ng/umbrella/commit/c6741bc))
|
|
83
101
|
|
|
102
|
+
### [2.3.1](https://github.com/thi-ng/umbrella/tree/@thi.ng/random@2.3.1) (2021-02-24)
|
|
84
103
|
|
|
104
|
+
#### 🩹 Bug fixes
|
|
85
105
|
|
|
86
|
-
|
|
106
|
+
- update weightedRandom() ([b1cf4d8](https://github.com/thi-ng/umbrella/commit/b1cf4d8))
|
|
107
|
+
- don't throw error if total weights <= 0 (only print warning)
|
|
87
108
|
|
|
88
|
-
|
|
109
|
+
## [2.3.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/random@2.3.0) (2021-02-20)
|
|
89
110
|
|
|
90
|
-
|
|
111
|
+
#### 🚀 Features
|
|
91
112
|
|
|
92
|
-
|
|
113
|
+
- add coin()/fairCoin() ([ed66a64](https://github.com/thi-ng/umbrella/commit/ed66a64))
|
|
93
114
|
|
|
94
|
-
|
|
115
|
+
#### ♻️ Refactoring
|
|
95
116
|
|
|
96
|
-
-
|
|
117
|
+
- update uuid() ([91372d9](https://github.com/thi-ng/umbrella/commit/91372d9))
|
|
118
|
+
- reuse fn from [@thi.ng/hex](https://github.com/thi-ng/umbrella/tree/main/packages/hex)
|
|
97
119
|
|
|
98
|
-
|
|
120
|
+
## [2.2.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/random@2.2.0) (2021-01-13)
|
|
99
121
|
|
|
100
|
-
|
|
122
|
+
#### 🚀 Features
|
|
101
123
|
|
|
102
|
-
|
|
124
|
+
- add CRYPTO IRandom impl ([94e69c1](https://github.com/thi-ng/umbrella/commit/94e69c1))
|
|
125
|
+
- add opt start/end for randomBytes() ([4d095da](https://github.com/thi-ng/umbrella/commit/4d095da))
|
|
103
126
|
|
|
104
|
-
|
|
127
|
+
#### 🩹 Bug fixes
|
|
105
128
|
|
|
106
|
-
-
|
|
129
|
+
- add opt start index arg for uuid() ([268ec3f](https://github.com/thi-ng/umbrella/commit/268ec3f))
|
|
107
130
|
|
|
108
|
-
|
|
131
|
+
#### ⏱ Performance improvements
|
|
109
132
|
|
|
110
|
-
|
|
133
|
+
- minor update weightedRandom() ([258fd7b](https://github.com/thi-ng/umbrella/commit/258fd7b))
|
|
134
|
+
- avoid sorting if no weights are given
|
|
111
135
|
|
|
112
|
-
|
|
136
|
+
#### ♻️ Refactoring
|
|
113
137
|
|
|
114
|
-
|
|
138
|
+
- minor update randomID() ([9d278ad](https://github.com/thi-ng/umbrella/commit/9d278ad))
|
|
115
139
|
|
|
116
|
-
###
|
|
140
|
+
### [2.1.2](https://github.com/thi-ng/umbrella/tree/@thi.ng/random@2.1.2) (2020-12-07)
|
|
117
141
|
|
|
118
|
-
|
|
142
|
+
#### ♻️ Refactoring
|
|
119
143
|
|
|
120
|
-
|
|
144
|
+
- update type-only imports in various tests/pkgs ([3fd9c24](https://github.com/thi-ng/umbrella/commit/3fd9c24))
|
|
121
145
|
|
|
122
|
-
|
|
123
|
-
- **random:** add opt start/end for randomBytes() ([4d095da](https://github.com/thi-ng/umbrella/commit/4d095da557b1f3ee9ce46778aeba25f0c6aa94f9))
|
|
146
|
+
### [2.1.1](https://github.com/thi-ng/umbrella/tree/@thi.ng/random@2.1.1) (2020-11-26)
|
|
124
147
|
|
|
125
|
-
|
|
148
|
+
#### 🩹 Bug fixes
|
|
126
149
|
|
|
127
|
-
-
|
|
150
|
+
- add missing subdir to pkg "files" ([916dbe7](https://github.com/thi-ng/umbrella/commit/916dbe7))
|
|
128
151
|
|
|
129
|
-
##
|
|
152
|
+
## [2.1.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/random@2.1.0) (2020-11-24)
|
|
130
153
|
|
|
131
|
-
|
|
154
|
+
#### 🚀 Features
|
|
132
155
|
|
|
133
|
-
-
|
|
156
|
+
- add distribution HOFs, move gaussian() ([9328821](https://github.com/thi-ng/umbrella/commit/9328821))
|
|
157
|
+
- add exponential(), geometric(), normal(), uniform() HOFs
|
|
158
|
+
- migrate gaussian() to /distributions
|
|
159
|
+
- add randomBytesFrom(), update UUID fns ([b31c872](https://github.com/thi-ng/umbrella/commit/b31c872))
|
|
160
|
+
- add [@thi.ng/hex](https://github.com/thi-ng/umbrella/tree/main/packages/hex) dependency
|
|
161
|
+
- update uuidv4Bytes() to take opt IRandom arg
|
|
162
|
+
- refactor/optimize uuid()
|
|
163
|
+
- add tests
|
|
134
164
|
|
|
135
|
-
#
|
|
165
|
+
# [2.0.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/random@2.0.0) (2020-08-28)
|
|
136
166
|
|
|
137
|
-
|
|
167
|
+
#### 🛑 Breaking changes
|
|
138
168
|
|
|
139
|
-
-
|
|
140
|
-
-
|
|
169
|
+
- add INorm, extract gaussianCLT() ([c687598](https://github.com/thi-ng/umbrella/commit/c687598))
|
|
170
|
+
- BREAKING CHANGE: remove gaussian() from IRandom,
|
|
171
|
+
extract as standalone gaussianCLT()
|
|
172
|
+
- update gaussianCLT() default args to be more meaningful
|
|
141
173
|
|
|
142
|
-
|
|
174
|
+
#### 🩹 Bug fixes
|
|
143
175
|
|
|
144
|
-
|
|
176
|
+
- off-by-one error in SYSTEM.int() ([ca0492d](https://github.com/thi-ng/umbrella/commit/ca0492d))
|
|
145
177
|
|
|
146
|
-
|
|
178
|
+
#### ♻️ Refactoring
|
|
147
179
|
|
|
148
|
-
|
|
180
|
+
- update imports/docstrings ([ecb2a36](https://github.com/thi-ng/umbrella/commit/ecb2a36))
|
|
149
181
|
|
|
150
|
-
|
|
182
|
+
## [1.4.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/random@1.4.0) (2020-03-01)
|
|
151
183
|
|
|
152
|
-
|
|
184
|
+
#### 🚀 Features
|
|
153
185
|
|
|
154
|
-
-
|
|
155
|
-
- update gaussianCLT() default args to be more meaningful
|
|
186
|
+
- add Xoshiro128, refactor default seeds ([b535628](https://github.com/thi-ng/umbrella/commit/b535628))
|
|
156
187
|
|
|
157
|
-
|
|
188
|
+
#### 🩹 Bug fixes
|
|
158
189
|
|
|
159
|
-
|
|
190
|
+
- use correct 160bit default seed for XorWow ([38d511b](https://github.com/thi-ng/umbrella/commit/38d511b))
|
|
160
191
|
|
|
161
|
-
|
|
192
|
+
## [1.3.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/random@1.3.0) (2020-02-25)
|
|
162
193
|
|
|
163
|
-
|
|
194
|
+
#### 🚀 Features
|
|
164
195
|
|
|
165
|
-
-
|
|
196
|
+
- add uuidv4Bytes() ([e9ea10f](https://github.com/thi-ng/umbrella/commit/e9ea10f))
|
|
166
197
|
|
|
167
|
-
|
|
198
|
+
#### ♻️ Refactoring
|
|
168
199
|
|
|
169
|
-
|
|
200
|
+
- update imports, internal restruct ([8548a80](https://github.com/thi-ng/umbrella/commit/8548a80))
|
|
170
201
|
|
|
171
|
-
|
|
202
|
+
## [1.2.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/random@1.2.0) (2020-01-26)
|
|
172
203
|
|
|
173
|
-
|
|
204
|
+
#### 🚀 Features
|
|
174
205
|
|
|
175
|
-
|
|
206
|
+
- add randomBytes() wrapper ([c536bcd](https://github.com/thi-ng/umbrella/commit/c536bcd))
|
|
176
207
|
|
|
177
|
-
|
|
208
|
+
### [1.1.15](https://github.com/thi-ng/umbrella/tree/@thi.ng/random@1.1.15) (2020-01-24)
|
|
178
209
|
|
|
179
|
-
|
|
210
|
+
#### ⏱ Performance improvements
|
|
180
211
|
|
|
181
|
-
|
|
212
|
+
- minor update ARandom.norm() ([babbbaa](https://github.com/thi-ng/umbrella/commit/babbbaa))
|
|
182
213
|
|
|
183
|
-
|
|
214
|
+
### [1.1.14](https://github.com/thi-ng/umbrella/tree/@thi.ng/random@1.1.14) (2019-11-30)
|
|
184
215
|
|
|
185
|
-
|
|
216
|
+
#### ♻️ Refactoring
|
|
186
217
|
|
|
187
|
-
|
|
218
|
+
- update weightedRandom ([d609182](https://github.com/thi-ng/umbrella/commit/d609182))
|
|
188
219
|
|
|
189
|
-
|
|
220
|
+
## [1.1.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/random@1.1.0) (2019-02-15)
|
|
190
221
|
|
|
191
|
-
|
|
222
|
+
#### 🚀 Features
|
|
192
223
|
|
|
193
|
-
-
|
|
224
|
+
- add randomID() & weightedRandom() ([f719724](https://github.com/thi-ng/umbrella/commit/f719724))
|
|
194
225
|
|
|
195
|
-
|
|
226
|
+
#### 🩹 Bug fixes
|
|
196
227
|
|
|
197
|
-
|
|
228
|
+
- add opt scale arg to IRandom.float() ([5a7e448](https://github.com/thi-ng/umbrella/commit/5a7e448))
|
|
198
229
|
|
|
199
|
-
|
|
230
|
+
# [1.0.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/random@1.0.0) (2019-01-21)
|
|
200
231
|
|
|
201
|
-
|
|
232
|
+
#### 🛑 Breaking changes
|
|
202
233
|
|
|
203
|
-
-
|
|
204
|
-
-
|
|
205
|
-
-
|
|
234
|
+
- update package build scripts & outputs, imports in ~50 packages ([b54b703](https://github.com/thi-ng/umbrella/commit/b54b703))
|
|
235
|
+
- BREAKING CHANGE: enabled multi-outputs (ES6 modules, CJS, UMD)
|
|
236
|
+
- build scripts now first build ES6 modules in package root, then call
|
|
237
|
+
`scripts/bundle-module` to build minified CJS & UMD bundles in `/lib`
|
|
238
|
+
- all imports MUST be updated to only refer to package level
|
|
239
|
+
(not individual files anymore). tree shaking in user land will get rid of
|
|
240
|
+
all unused imported symbols.
|
|
206
241
|
|
|
207
|
-
|
|
242
|
+
## [0.1.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/random@0.1.0) (2018-11-24)
|
|
208
243
|
|
|
209
|
-
|
|
244
|
+
#### 🚀 Features
|
|
210
245
|
|
|
211
|
-
-
|
|
246
|
+
- re-import, extend & refactor random package (MBP2010) ([4aea85d](https://github.com/thi-ng/umbrella/commit/4aea85d))
|
package/README.md
CHANGED
package/package.json
CHANGED
|
@@ -1,152 +1,157 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
"
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
"
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
"
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
"
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
"
|
|
152
|
-
|
|
2
|
+
"name": "@thi.ng/random",
|
|
3
|
+
"version": "3.2.1",
|
|
4
|
+
"description": "Pseudo-random number generators w/ unified API, distributions, weighted choices, ID generation",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"module": "./index.js",
|
|
7
|
+
"typings": "./index.d.ts",
|
|
8
|
+
"sideEffects": false,
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "https://github.com/thi-ng/umbrella.git"
|
|
12
|
+
},
|
|
13
|
+
"homepage": "https://github.com/thi-ng/umbrella/tree/develop/packages/random#readme",
|
|
14
|
+
"funding": [
|
|
15
|
+
{
|
|
16
|
+
"type": "github",
|
|
17
|
+
"url": "https://github.com/sponsors/postspectacular"
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
"type": "patreon",
|
|
21
|
+
"url": "https://patreon.com/thing_umbrella"
|
|
22
|
+
}
|
|
23
|
+
],
|
|
24
|
+
"author": "Karsten Schmidt <k+npm@thi.ng>",
|
|
25
|
+
"license": "Apache-2.0",
|
|
26
|
+
"scripts": {
|
|
27
|
+
"build": "yarn clean && tsc --declaration",
|
|
28
|
+
"clean": "rimraf '*.js' '*.d.ts' '*.map' doc distributions",
|
|
29
|
+
"doc": "typedoc --excludePrivate --excludeInternal --out doc src/index.ts",
|
|
30
|
+
"doc:ae": "mkdir -p .ae/doc .ae/temp && api-extractor run --local --verbose",
|
|
31
|
+
"doc:readme": "yarn doc:stats && tools:readme",
|
|
32
|
+
"doc:stats": "tools:module-stats",
|
|
33
|
+
"pub": "yarn npm publish --access public",
|
|
34
|
+
"test": "testament test"
|
|
35
|
+
},
|
|
36
|
+
"dependencies": {
|
|
37
|
+
"@thi.ng/api": "^8.3.1",
|
|
38
|
+
"@thi.ng/checks": "^3.1.1",
|
|
39
|
+
"@thi.ng/errors": "^2.1.1",
|
|
40
|
+
"@thi.ng/hex": "^2.1.1"
|
|
41
|
+
},
|
|
42
|
+
"devDependencies": {
|
|
43
|
+
"@microsoft/api-extractor": "^7.18.19",
|
|
44
|
+
"@thi.ng/testament": "^0.2.1",
|
|
45
|
+
"rimraf": "^3.0.2",
|
|
46
|
+
"tools": "^0.0.1",
|
|
47
|
+
"typedoc": "^0.22.9",
|
|
48
|
+
"typescript": "^4.5.2"
|
|
49
|
+
},
|
|
50
|
+
"keywords": [
|
|
51
|
+
"binary",
|
|
52
|
+
"crypto",
|
|
53
|
+
"datastructure",
|
|
54
|
+
"distribution",
|
|
55
|
+
"exponential",
|
|
56
|
+
"gaussian",
|
|
57
|
+
"generator",
|
|
58
|
+
"geometric",
|
|
59
|
+
"normal",
|
|
60
|
+
"prng",
|
|
61
|
+
"random",
|
|
62
|
+
"typedarray",
|
|
63
|
+
"typescript",
|
|
64
|
+
"weighted",
|
|
65
|
+
"uuid",
|
|
66
|
+
"uniform"
|
|
67
|
+
],
|
|
68
|
+
"publishConfig": {
|
|
69
|
+
"access": "public"
|
|
70
|
+
},
|
|
71
|
+
"engines": {
|
|
72
|
+
"node": ">=12.7"
|
|
73
|
+
},
|
|
74
|
+
"files": [
|
|
75
|
+
"*.js",
|
|
76
|
+
"*.d.ts",
|
|
77
|
+
"distributions"
|
|
78
|
+
],
|
|
79
|
+
"exports": {
|
|
80
|
+
".": {
|
|
81
|
+
"import": "./index.js"
|
|
82
|
+
},
|
|
83
|
+
"./api": {
|
|
84
|
+
"import": "./api.js"
|
|
85
|
+
},
|
|
86
|
+
"./arandom": {
|
|
87
|
+
"import": "./arandom.js"
|
|
88
|
+
},
|
|
89
|
+
"./coin": {
|
|
90
|
+
"import": "./coin.js"
|
|
91
|
+
},
|
|
92
|
+
"./constants": {
|
|
93
|
+
"import": "./constants.js"
|
|
94
|
+
},
|
|
95
|
+
"./crypto": {
|
|
96
|
+
"import": "./crypto.js"
|
|
97
|
+
},
|
|
98
|
+
"./distributions/exponential": {
|
|
99
|
+
"import": "./distributions/exponential.js"
|
|
100
|
+
},
|
|
101
|
+
"./distributions/gaussian": {
|
|
102
|
+
"import": "./distributions/gaussian.js"
|
|
103
|
+
},
|
|
104
|
+
"./distributions/geometric": {
|
|
105
|
+
"import": "./distributions/geometric.js"
|
|
106
|
+
},
|
|
107
|
+
"./distributions/normal": {
|
|
108
|
+
"import": "./distributions/normal.js"
|
|
109
|
+
},
|
|
110
|
+
"./distributions/uniform": {
|
|
111
|
+
"import": "./distributions/uniform.js"
|
|
112
|
+
},
|
|
113
|
+
"./pick-random": {
|
|
114
|
+
"import": "./pick-random.js"
|
|
115
|
+
},
|
|
116
|
+
"./random-bytes": {
|
|
117
|
+
"import": "./random-bytes.js"
|
|
118
|
+
},
|
|
119
|
+
"./random-id": {
|
|
120
|
+
"import": "./random-id.js"
|
|
121
|
+
},
|
|
122
|
+
"./smush32": {
|
|
123
|
+
"import": "./smush32.js"
|
|
124
|
+
},
|
|
125
|
+
"./system": {
|
|
126
|
+
"import": "./system.js"
|
|
127
|
+
},
|
|
128
|
+
"./unique-indices": {
|
|
129
|
+
"import": "./unique-indices.js"
|
|
130
|
+
},
|
|
131
|
+
"./uuid": {
|
|
132
|
+
"import": "./uuid.js"
|
|
133
|
+
},
|
|
134
|
+
"./weighted-random": {
|
|
135
|
+
"import": "./weighted-random.js"
|
|
136
|
+
},
|
|
137
|
+
"./xorshift128": {
|
|
138
|
+
"import": "./xorshift128.js"
|
|
139
|
+
},
|
|
140
|
+
"./xorwow": {
|
|
141
|
+
"import": "./xorwow.js"
|
|
142
|
+
},
|
|
143
|
+
"./xoshiro128": {
|
|
144
|
+
"import": "./xoshiro128.js"
|
|
145
|
+
},
|
|
146
|
+
"./xsadd": {
|
|
147
|
+
"import": "./xsadd.js"
|
|
148
|
+
}
|
|
149
|
+
},
|
|
150
|
+
"thi.ng": {
|
|
151
|
+
"year": 2015,
|
|
152
|
+
"related": [
|
|
153
|
+
"ksuid"
|
|
154
|
+
]
|
|
155
|
+
},
|
|
156
|
+
"gitHead": "8bd27c8bde0b770e7c001943f11c951cd345d668\n"
|
|
157
|
+
}
|
package/random-id.js
CHANGED
|
@@ -23,7 +23,7 @@ import { SYSTEM } from "./system.js";
|
|
|
23
23
|
*/
|
|
24
24
|
export const randomID = (len = 4, prefix = "", syms = "abcdefghijklmnopqrstuvwxyz", rnd = SYSTEM) => {
|
|
25
25
|
const n = syms.length;
|
|
26
|
-
for (; --
|
|
26
|
+
for (; len-- > 0;) {
|
|
27
27
|
prefix += syms[rnd.int() % n];
|
|
28
28
|
}
|
|
29
29
|
return prefix;
|