fix(fragments): prevent adding the same spec instance more than once

This commit is contained in:
Folke Lemaitre 2024-06-24 16:42:57 +02:00
parent fd04bc62f9
commit dbffad6f44
5 changed files with 65 additions and 37 deletions

View file

@ -28,6 +28,20 @@ function M.track(data, time)
end
end
---@generic T
---@param list T[]
---@param fn fun(v: T):boolean?
---@return T[]
function M.filter(fn, list)
local ret = {}
for _, v in ipairs(list) do
if fn(v) then
table.insert(ret, v)
end
end
return ret
end
---@generic F: fun()
---@param data (string|{[string]:string})?
---@param fn F