@quenty/defaultvalueutils 1.2.0 → 1.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 +11 -0
- package/package.json +2 -2
- package/src/Shared/DefaultValueUtils.lua +31 -27
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
|
+
## [1.2.1](https://github.com/Quenty/NevermoreEngine/compare/@quenty/defaultvalueutils@1.2.0...@quenty/defaultvalueutils@1.2.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
|
# [1.2.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/defaultvalueutils@1.1.0...@quenty/defaultvalueutils@1.2.0) (2024-05-09)
|
|
7
18
|
|
|
8
19
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quenty/defaultvalueutils",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.1",
|
|
4
4
|
"description": "Helps get the default or zero value for value types in Roblox",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Roblox",
|
|
@@ -27,5 +27,5 @@
|
|
|
27
27
|
"publishConfig": {
|
|
28
28
|
"access": "public"
|
|
29
29
|
},
|
|
30
|
-
"gitHead": "
|
|
30
|
+
"gitHead": "78c3ac0ab08dd18085b6e6e6e4f745e76ed99f68"
|
|
31
31
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
--!strict
|
|
1
2
|
--[=[
|
|
2
3
|
Helps get the default or zero value for value types in Roblox
|
|
3
4
|
@class DefaultValueUtils
|
|
@@ -7,29 +8,32 @@ local DefaultValueUtils = {}
|
|
|
7
8
|
|
|
8
9
|
-- selene: allow(incorrect_standard_library_use)
|
|
9
10
|
local DEFAULT_VALUES = {
|
|
10
|
-
["boolean"] = false
|
|
11
|
-
["BrickColor"] = BrickColor.new()
|
|
12
|
-
["CFrame"] = CFrame.new()
|
|
13
|
-
["Color3"] = Color3.new()
|
|
14
|
-
["ColorSequence"] = ColorSequence.new({
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
["
|
|
19
|
-
["
|
|
20
|
-
["
|
|
21
|
-
["
|
|
22
|
-
["
|
|
23
|
-
["
|
|
24
|
-
["
|
|
25
|
-
["
|
|
26
|
-
["
|
|
27
|
-
["
|
|
28
|
-
["
|
|
29
|
-
["
|
|
30
|
-
["
|
|
31
|
-
["
|
|
32
|
-
["
|
|
11
|
+
["boolean"] = false,
|
|
12
|
+
["BrickColor"] = (BrickColor :: any).new(),
|
|
13
|
+
["CFrame"] = CFrame.new(),
|
|
14
|
+
["Color3"] = Color3.new(),
|
|
15
|
+
["ColorSequence"] = ColorSequence.new({
|
|
16
|
+
ColorSequenceKeypoint.new(0, Color3.new(0, 0, 0)),
|
|
17
|
+
ColorSequenceKeypoint.new(1, Color3.new(0, 0, 0)),
|
|
18
|
+
}),
|
|
19
|
+
["ColorSequenceKeypoint"] = ColorSequenceKeypoint.new(0, Color3.new(0, 0, 0)),
|
|
20
|
+
["number"] = 0,
|
|
21
|
+
["PhysicalProperties"] = PhysicalProperties.new(Enum.Material.Plastic), -- Eww
|
|
22
|
+
["NumberRange"] = NumberRange.new(0),
|
|
23
|
+
["NumberSequence"] = NumberSequence.new({ NumberSequenceKeypoint.new(0, 0), NumberSequenceKeypoint.new(1, 0) }),
|
|
24
|
+
["NumberSequenceKeypoint"] = NumberSequenceKeypoint.new(0, 0),
|
|
25
|
+
["Ray"] = (Ray :: any).new(),
|
|
26
|
+
["Rect"] = Rect.new(),
|
|
27
|
+
["Region3"] = (Region3 :: any).new(),
|
|
28
|
+
["Region3int16"] = (Region3int16 :: any).new(),
|
|
29
|
+
["string"] = "",
|
|
30
|
+
["UDim"] = UDim.new(),
|
|
31
|
+
["UDim2"] = UDim2.new(),
|
|
32
|
+
["userdata"] = newproxy(),
|
|
33
|
+
["Vector2"] = Vector2.zero,
|
|
34
|
+
["Vector2int16"] = Vector2int16.new(),
|
|
35
|
+
["Vector3"] = Vector3.zero,
|
|
36
|
+
["Vector3int16"] = Vector3int16.new(),
|
|
33
37
|
}
|
|
34
38
|
|
|
35
39
|
--[=[
|
|
@@ -39,7 +43,7 @@ local DEFAULT_VALUES = {
|
|
|
39
43
|
@param typeOfName string
|
|
40
44
|
@return any
|
|
41
45
|
]=]
|
|
42
|
-
function DefaultValueUtils.getDefaultValueForType(typeOfName)
|
|
46
|
+
function DefaultValueUtils.getDefaultValueForType(typeOfName: string)
|
|
43
47
|
if DEFAULT_VALUES[typeOfName] ~= nil then
|
|
44
48
|
return DEFAULT_VALUES[typeOfName]
|
|
45
49
|
elseif typeOfName == "table" then
|
|
@@ -65,10 +69,10 @@ end
|
|
|
65
69
|
@param value T
|
|
66
70
|
@return T
|
|
67
71
|
]=]
|
|
68
|
-
function DefaultValueUtils.toDefaultValue(value)
|
|
72
|
+
function DefaultValueUtils.toDefaultValue(value: any): any
|
|
69
73
|
if type(value) == "table" then
|
|
70
74
|
local result = {}
|
|
71
|
-
for key, item in
|
|
75
|
+
for key, item in value do
|
|
72
76
|
result[key] = DefaultValueUtils.toDefaultValue(item)
|
|
73
77
|
end
|
|
74
78
|
return result
|
|
@@ -77,4 +81,4 @@ function DefaultValueUtils.toDefaultValue(value)
|
|
|
77
81
|
end
|
|
78
82
|
end
|
|
79
83
|
|
|
80
|
-
return DefaultValueUtils
|
|
84
|
+
return DefaultValueUtils
|