feat(util): Snacks.util.stop() to safely stop/close a luv handle

This commit is contained in:
Folke Lemaitre 2025-10-27 23:37:45 +01:00
parent 5589c9d355
commit ce9e2993dd
No known key found for this signature in database
GPG key ID: 9B52594D560070AB

View file

@ -468,6 +468,16 @@ function M.parse(parser, range, on_parse)
end
end
---@param handle? uv.uv_handle_t|uv.uv_timer_t
function M.stop(handle)
if handle and not handle:is_closing() then
if handle.stop then
handle:stop()
end
handle:close()
end
end
--- Better validation to check if path is a dir or a file
---@param path string
---@return "directory"|"file"