@quenty/randomutils 6.10.0 → 6.10.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
CHANGED
|
@@ -3,6 +3,17 @@
|
|
|
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
|
+
## [6.10.1](https://github.com/Quenty/NevermoreEngine/compare/@quenty/randomutils@6.10.0...@quenty/randomutils@6.10.1) (2025-04-05)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* Add types to packages ([2374fb2](https://github.com/Quenty/NevermoreEngine/commit/2374fb2b043cfbe0e9b507b3316eec46a4e353a0))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
6
17
|
# [6.10.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/randomutils@6.9.1...@quenty/randomutils@6.10.0) (2025-04-02)
|
|
7
18
|
|
|
8
19
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quenty/randomutils",
|
|
3
|
-
"version": "6.10.
|
|
3
|
+
"version": "6.10.1",
|
|
4
4
|
"description": "Quenty's RandomUtils, utility functions for Roblox",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Roblox",
|
|
@@ -29,8 +29,8 @@
|
|
|
29
29
|
"access": "public"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@quenty/loader": "^10.8.
|
|
33
|
-
"@quenty/table": "^3.7.
|
|
32
|
+
"@quenty/loader": "^10.8.1",
|
|
33
|
+
"@quenty/table": "^3.7.2"
|
|
34
34
|
},
|
|
35
|
-
"gitHead": "
|
|
35
|
+
"gitHead": "78c3ac0ab08dd18085b6e6e6e4f745e76ed99f68"
|
|
36
36
|
}
|
|
@@ -21,6 +21,7 @@ function RandomSampler.new(samples)
|
|
|
21
21
|
|
|
22
22
|
self._optionsList = {}
|
|
23
23
|
self._shuffledAvailableList = {}
|
|
24
|
+
self._lastSelection = nil
|
|
24
25
|
|
|
25
26
|
if samples then
|
|
26
27
|
self:SetSamples(samples)
|
|
@@ -34,7 +35,7 @@ end
|
|
|
34
35
|
|
|
35
36
|
@param samples { T } -- The list of samples to sample from
|
|
36
37
|
]=]
|
|
37
|
-
function RandomSampler:SetSamples(samples)
|
|
38
|
+
function RandomSampler:SetSamples<T>(samples: { T })
|
|
38
39
|
assert(type(samples) == "table", "Bad samples")
|
|
39
40
|
|
|
40
41
|
if self._optionsList ~= samples then
|
|
@@ -28,7 +28,7 @@ end
|
|
|
28
28
|
removes the option.
|
|
29
29
|
|
|
30
30
|
@param option T
|
|
31
|
-
@param weight number
|
|
31
|
+
@param weight number?
|
|
32
32
|
]=]
|
|
33
33
|
function WeightedRandomChooser:SetWeight(option, weight)
|
|
34
34
|
assert(option ~= nil, "Bad option")
|
|
@@ -55,7 +55,7 @@ end
|
|
|
55
55
|
Gets the weight for the option
|
|
56
56
|
|
|
57
57
|
@param option T
|
|
58
|
-
@return number
|
|
58
|
+
@return number?
|
|
59
59
|
]=]
|
|
60
60
|
function WeightedRandomChooser:GetWeight(option): number?
|
|
61
61
|
return self._optionToWeight[option]
|
|
@@ -65,7 +65,7 @@ end
|
|
|
65
65
|
Gets the percent probability from 0 to 1
|
|
66
66
|
|
|
67
67
|
@param option T
|
|
68
|
-
@return number
|
|
68
|
+
@return number?
|
|
69
69
|
]=]
|
|
70
70
|
function WeightedRandomChooser:GetProbability(option): number?
|
|
71
71
|
local weight = self._optionToWeight[option]
|
|
@@ -119,7 +119,7 @@ function WeightedRandomChooser:_getOrCreateDataCache()
|
|
|
119
119
|
local weights = {}
|
|
120
120
|
|
|
121
121
|
local total = 0
|
|
122
|
-
for index, key in
|
|
122
|
+
for index, key in options do
|
|
123
123
|
local weight = self._optionToWeight[key]
|
|
124
124
|
total = total + weight
|
|
125
125
|
weights[index] = weight
|