mirror of
https://github.com/folke/lazy.nvim.git
synced 2025-06-28 03:24:13 +00:00
feat: utility methods to read/write files
This commit is contained in:
parent
a2f0637c77
commit
27178b5e67
1 changed files with 14 additions and 0 deletions
|
@ -28,6 +28,20 @@ function M.open(uri)
|
||||||
end
|
end
|
||||||
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 ms number
|
||||||
---@param fn fun()
|
---@param fn fun()
|
||||||
function M.throttle(ms, fn)
|
function M.throttle(ms, fn)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue