This commit is contained in:
Lucas F. 2024-12-10 19:07:29 -03:00
commit 5931cb012f
9 changed files with 900 additions and 0 deletions

17
lua/django/lazy.lua Normal file
View file

@ -0,0 +1,17 @@
local lazy = {}
--- Require on index.
---
--- Will only require the module after the first index of a module.
--- Only works for modules that export a table.
---@param require_path string
---@return table
lazy.require = function(require_path)
return setmetatable({}, {
__index = function(_, key) return require(require_path)[key] end,
__newindex = function(_, key, value) require(require_path)[key] = value end,
})
end
return lazy