timer.lua
Branches > main > c6f0089 > files / nvim / pack / plugins / opt / conjure / lua / conjure / timer.lua
-- [nfnl] fnl/conjure/timer.fnl
local _local_1_ = require("conjure.nfnl.module")
local define = _local_1_.define
local vim = _G.vim
local M = define("conjure.timer")
M.defer = function(f, ms)
local t = vim.uv.new_timer()
t:start(ms, 0, vim.schedule_wrap(f))
return t
end
M.destroy = function(t)
if t then
t:stop()
t:close()
else
end
return nil
end
M.interval = function(ms, f)
local t = vim.uv.new_timer()
t:start(ms, ms, vim.schedule_wrap(f))
return t
end
return M