-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathPropsUtil.lua
More file actions
40 lines (31 loc) · 1.04 KB
/
PropsUtil.lua
File metadata and controls
40 lines (31 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Fusion = require(ReplicatedStorage.Packages.Fusion)
local PropsUtil = {}
PropsUtil.NIL = newproxy()
-- Takes the old props and combines them with the new ones, overwriting any existing keys and combining children.
--
-- Use `PropsUtil.NIL` to replace values with nil.
function PropsUtil.PatchProps(oldProps, newProps)
local result = table.clone(oldProps)
for key, value in newProps do
if value == PropsUtil.NIL then
result[key] = nil
elseif key == Fusion.Children and typeof(value) == "table" and result[key] then
for _, value2 in value do
table.insert(result[key], value2)
end
else
result[key] = value
end
end
return result
end
-- Strips the specified props from the table.
function PropsUtil.StripProps(props, toStrip)
local stripped = table.clone(props)
for _, value in toStrip do
stripped[value] = nil
end
return stripped
end
return PropsUtil