#1059 protect against duplicates (#1143)

This commit is contained in:
Alexander Courtis
2022-04-09 22:59:38 +10:00
committed by GitHub
parent deb1f253f4
commit 1bdef08cfa
3 changed files with 15 additions and 10 deletions

View File

@@ -210,4 +210,12 @@ function M.format_bytes(bytes)
return (units[pow] == nil) and (bytes .. "B") or (value .. units[pow])
end
function M.key_by(tbl, key)
local keyed = {}
for _, val in ipairs(tbl) do
keyed[val[key]] = val
end
return keyed
end
return M