@quenty/observablecollection 10.0.0 → 11.0.0
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
|
+
# [11.0.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/observablecollection@10.0.0...@quenty/observablecollection@11.0.0) (2024-02-14)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* Fix sorting errors ([43ac468](https://github.com/Quenty/NevermoreEngine/commit/43ac468dd49147011c04e9d61e08573fb543423c))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
6
17
|
# [10.0.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/observablecollection@9.0.0...@quenty/observablecollection@10.0.0) (2024-02-13)
|
|
7
18
|
|
|
8
19
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quenty/observablecollection",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "11.0.0",
|
|
4
4
|
"description": "A set of observable collections, such as sets, maps, sorted lists, and more.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Roblox",
|
|
@@ -45,5 +45,5 @@
|
|
|
45
45
|
"publishConfig": {
|
|
46
46
|
"access": "public"
|
|
47
47
|
},
|
|
48
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "77d0a0b5b59a512311fa07293fb573953fcacbeb"
|
|
49
49
|
}
|
|
@@ -15,7 +15,14 @@ FilteredObservableListView.__index = FilteredObservableListView
|
|
|
15
15
|
|
|
16
16
|
-- Higher numbers last
|
|
17
17
|
local function defaultCompare(a, b)
|
|
18
|
-
return a
|
|
18
|
+
-- equivalent of `return a - b` except it supports comparison of strings and stuff
|
|
19
|
+
if b > a then
|
|
20
|
+
return -1
|
|
21
|
+
elseif b < a then
|
|
22
|
+
return 1
|
|
23
|
+
else
|
|
24
|
+
return 0
|
|
25
|
+
end
|
|
19
26
|
end
|
|
20
27
|
|
|
21
28
|
function FilteredObservableListView.new(observableList, observeScoreCallback, compare)
|
|
@@ -25,15 +32,14 @@ function FilteredObservableListView.new(observableList, observeScoreCallback, co
|
|
|
25
32
|
self._baseList = assert(observableList, "No observableList")
|
|
26
33
|
self._observeScoreCallback = assert(observeScoreCallback, "No observeScoreCallback")
|
|
27
34
|
|
|
28
|
-
self._scoredList = ObservableSortedList.new(false, function(a, b)
|
|
35
|
+
self._scoredList = self._maid:Add(ObservableSortedList.new(false, function(a, b)
|
|
29
36
|
-- Preserve index when scoring does not
|
|
30
37
|
if a.score == b.score then
|
|
31
38
|
return a.index - b.index
|
|
32
39
|
else
|
|
33
40
|
return self._compare(a.score, b.score)
|
|
34
41
|
end
|
|
35
|
-
end)
|
|
36
|
-
self._maid:GiveTask(self._scoredList)
|
|
42
|
+
end))
|
|
37
43
|
|
|
38
44
|
-- Shockingly this is somewhat performant because the sorted list defers all events
|
|
39
45
|
-- to process the list reordering.
|
|
@@ -58,8 +64,6 @@ function FilteredObservableListView.new(observableList, observeScoreCallback, co
|
|
|
58
64
|
return state
|
|
59
65
|
end)
|
|
60
66
|
}))
|
|
61
|
-
|
|
62
|
-
|
|
63
67
|
end))
|
|
64
68
|
|
|
65
69
|
return self
|
|
@@ -632,7 +632,9 @@ function ObservableSortedList:_highBinarySearch(sortValue)
|
|
|
632
632
|
while true do
|
|
633
633
|
local mid = math.floor((minIndex + maxIndex) / 2)
|
|
634
634
|
local compareValue = self._compare(self._sortValue[self._keyList[mid]], sortValue)
|
|
635
|
-
|
|
635
|
+
if type(compareValue) ~= "number" then
|
|
636
|
+
error(string.format("Bad compareValue, expected number, got %q", type(compareValue)))
|
|
637
|
+
end
|
|
636
638
|
|
|
637
639
|
if self._isReversed then
|
|
638
640
|
compareValue = -compareValue
|