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