Skip to content

Commit

Permalink
feat: utility methods to read/write files
Browse files Browse the repository at this point in the history
  • Loading branch information
folke committed Dec 15, 2022
1 parent a2f0637 commit 27178b5
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions lua/lazy/util.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 27178b5

Please sign in to comment.