mirror of
https://github.com/appgurueu/modlib.git
synced 2024-11-22 23:33:53 +01:00
table: get rid of unneeded metatable duplication
This commit is contained in:
parent
5e3fd2048e
commit
ca6757f326
@ -1,14 +1,15 @@
|
|||||||
-- Table helpers
|
-- Table helpers
|
||||||
|
|
||||||
function map_index(table, func)
|
function map_index(table, func)
|
||||||
return setmetatable(table, {
|
local mapping_metatable = {
|
||||||
__index = function(table, key)
|
__index = function(table, key)
|
||||||
return rawget(table, func(key))
|
return rawget(table, func(key))
|
||||||
end,
|
end,
|
||||||
__newindex = function(table, key, value)
|
__newindex = function(table, key, value)
|
||||||
rawset(table, func(key), value)
|
rawset(table, func(key), value)
|
||||||
end
|
end
|
||||||
})
|
}
|
||||||
|
return setmetatable(table, mapping_metatable)
|
||||||
end
|
end
|
||||||
|
|
||||||
function set_case_insensitive_index(table)
|
function set_case_insensitive_index(table)
|
||||||
|
Loading…
Reference in New Issue
Block a user