mirror of https://github.com/folke/lazy.nvim.git
feat: utility methods to read/write files
This commit is contained in:
parent
a2f0637c77
commit
27178b5e67
|
@ -28,6 +28,20 @@ function M.open(uri)
|
|||
end
|
||||
end
|
||||
|
||||
function M.read_file(file)
|
||||
local fd = assert(io.open(file, "r"))
|
||||
---@type string
|
||||
local data = fd:read("*a")
|
||||
fd:close()
|
||||
return data
|
||||
end
|
||||
|
||||
function M.write_file(file, contents)
|
||||
local fd = assert(io.open(file, "w+"))
|
||||
fd:write(contents)
|
||||
fd:close()
|
||||
end
|
||||
|
||||
---@param ms number
|
||||
---@param fn fun()
|
||||
function M.throttle(ms, fn)
|
||||
|
|
Loading…
Reference in New Issue