mirror of
https://github.com/johndoe6345789/metabuilder.git
synced 2026-04-25 14:25:02 +00:00
26 lines
644 B
Lua
26 lines
644 B
Lua
--- Update a step in the list
|
|
---@param steps Step[] Array of steps
|
|
---@param stepId string ID of step to update
|
|
---@param updates table Partial step updates
|
|
---@return Step[] Updated steps array
|
|
local function update_step(steps, stepId, updates)
|
|
local result = {}
|
|
for i, step in ipairs(steps) do
|
|
if step.id == stepId then
|
|
local updatedStep = {}
|
|
for k, v in pairs(step) do
|
|
updatedStep[k] = v
|
|
end
|
|
for k, v in pairs(updates) do
|
|
updatedStep[k] = v
|
|
end
|
|
result[i] = updatedStep
|
|
else
|
|
result[i] = step
|
|
end
|
|
end
|
|
return result
|
|
end
|
|
|
|
return update_step
|