@quenty/observablecollection 12.20.0 → 12.20.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 +11 -0
- package/package.json +15 -15
- package/src/Shared/ObservableCountingMap.lua +102 -81
- package/src/Shared/ObservableList.lua +91 -70
- package/src/Shared/ObservableMap.lua +100 -78
- package/src/Shared/ObservableMapList.lua +2 -2
- package/src/Shared/ObservableMapSet.lua +83 -41
- package/src/Shared/ObservableSet.lua +61 -34
- package/src/Shared/SortedList/ObservableSortedList.lua +128 -58
- package/src/Shared/SortedList/ObservableSortedList.story.lua +1 -1
- package/src/Shared/SortedList/SortFunctionUtils.lua +25 -8
- package/src/Shared/SortedList/SortedNode.lua +231 -116
- package/src/Shared/SortedList/SortedNodeValue.lua +17 -6
- package/src/Shared/Utils/ListIndexUtils.lua +9 -2
- package/test/scripts/Server/ServerMain.server.lua +1 -1
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
--!strict
|
|
1
2
|
--[=[
|
|
2
3
|
Simplifies comparison logic
|
|
3
4
|
|
|
@@ -12,7 +13,17 @@ local SortedNodeValue = {}
|
|
|
12
13
|
SortedNodeValue.ClassName = "SortedNodeValue"
|
|
13
14
|
SortedNodeValue.__index = SortedNodeValue
|
|
14
15
|
|
|
15
|
-
|
|
16
|
+
export type CompareFunction<T> = (T, T) -> number
|
|
17
|
+
|
|
18
|
+
export type SortedNodeValue<T> = typeof(setmetatable(
|
|
19
|
+
{} :: {
|
|
20
|
+
_value: T,
|
|
21
|
+
_compare: CompareFunction<T>,
|
|
22
|
+
},
|
|
23
|
+
SortedNodeValue
|
|
24
|
+
))
|
|
25
|
+
|
|
26
|
+
function SortedNodeValue.new<T>(value: T, compare: CompareFunction<T>): SortedNodeValue<T>
|
|
16
27
|
local self = setmetatable({}, SortedNodeValue)
|
|
17
28
|
|
|
18
29
|
self._value = value
|
|
@@ -21,29 +32,29 @@ function SortedNodeValue.new(value, compare)
|
|
|
21
32
|
return self
|
|
22
33
|
end
|
|
23
34
|
|
|
24
|
-
function SortedNodeValue
|
|
35
|
+
function SortedNodeValue.GetValue<T>(self: SortedNodeValue<T>): T
|
|
25
36
|
return self._value
|
|
26
37
|
end
|
|
27
38
|
|
|
28
|
-
function SortedNodeValue.isSortedNodeValue(value)
|
|
39
|
+
function SortedNodeValue.isSortedNodeValue(value: any): boolean
|
|
29
40
|
return DuckTypeUtils.isImplementation(SortedNodeValue, value)
|
|
30
41
|
end
|
|
31
42
|
|
|
32
|
-
function SortedNodeValue
|
|
43
|
+
function SortedNodeValue.__eq<T>(self: SortedNodeValue<T>, other: SortedNodeValue<T>): boolean
|
|
33
44
|
assert(SortedNodeValue.isSortedNodeValue(other), "Bad other")
|
|
34
45
|
assert(other._compare == self._compare, "Bad compare")
|
|
35
46
|
|
|
36
47
|
return self._compare(self._value, other._value) == 0
|
|
37
48
|
end
|
|
38
49
|
|
|
39
|
-
function SortedNodeValue
|
|
50
|
+
function SortedNodeValue.__lt<T>(self: SortedNodeValue<T>, other: SortedNodeValue<T>): boolean
|
|
40
51
|
assert(SortedNodeValue.isSortedNodeValue(other), "Bad other")
|
|
41
52
|
assert(other._compare == self._compare, "Bad compare")
|
|
42
53
|
|
|
43
54
|
return self._compare(self._value, other._value) < 0
|
|
44
55
|
end
|
|
45
56
|
|
|
46
|
-
function SortedNodeValue
|
|
57
|
+
function SortedNodeValue.__gt<T>(self: SortedNodeValue<T>, other: SortedNodeValue<T>): boolean
|
|
47
58
|
assert(SortedNodeValue.isSortedNodeValue(other), "Bad other")
|
|
48
59
|
assert(other._compare == self._compare, "Bad compare")
|
|
49
60
|
|
|
@@ -1,13 +1,16 @@
|
|
|
1
|
+
--!strict
|
|
1
2
|
--[=[
|
|
2
3
|
@class ListIndexUtils
|
|
3
4
|
]=]
|
|
4
5
|
|
|
5
|
-
local require = require(script.Parent.loader).load(script)
|
|
6
|
-
|
|
7
6
|
local ListIndexUtils = {}
|
|
8
7
|
|
|
9
8
|
--[=[
|
|
10
9
|
Converts a negative index to a positive one for the list indexing
|
|
10
|
+
|
|
11
|
+
@param listLength number
|
|
12
|
+
@param index number
|
|
13
|
+
@return number
|
|
11
14
|
]=]
|
|
12
15
|
function ListIndexUtils.toPositiveIndex(listLength: number, index: number): number
|
|
13
16
|
assert(type(listLength) == "number", "Bad listLength")
|
|
@@ -24,6 +27,10 @@ end
|
|
|
24
27
|
|
|
25
28
|
--[=[
|
|
26
29
|
Converts a positive index to a negative one for list indexing
|
|
30
|
+
|
|
31
|
+
@param listLength number
|
|
32
|
+
@param index number
|
|
33
|
+
@return number
|
|
27
34
|
]=]
|
|
28
35
|
function ListIndexUtils.toNegativeIndex(listLength: number, index: number): number
|
|
29
36
|
assert(type(listLength) == "number", "Bad listLength")
|
|
@@ -26,7 +26,7 @@ observableSortedList:ObserveItemsBrio():Subscribe(function(brio)
|
|
|
26
26
|
local maid = brio:ToMaid()
|
|
27
27
|
|
|
28
28
|
local currentTween
|
|
29
|
-
local function setCFrame(cframe, doNotAnimate)
|
|
29
|
+
local function setCFrame(cframe: CFrame, doNotAnimate: boolean?)
|
|
30
30
|
if currentTween then
|
|
31
31
|
currentTween:Cancel()
|
|
32
32
|
currentTween = nil
|