Skip to content

Instantly share code, notes, and snippets.

@jikanter
Last active December 26, 2024 20:25
Show Gist options
  • Select an option

  • Save jikanter/4b455f57c1392f85723f3a5ed4d3b78f to your computer and use it in GitHub Desktop.

Select an option

Save jikanter/4b455f57c1392f85723f3a5ed4d3b78f to your computer and use it in GitHub Desktop.
[Inspect Table] #hammerspoon #lua
-- A robust table inspection utility
function inspectTable(t, method)
if (method == "inspect") then
print(hs.inspect(t))
elseif (method == "keys") then
for k, v in pairs(t) do
print(k)
end
elseif (method == "metatable") then
if (t.__metatable ~= nil) then
for k, v in pairs(t.__metatable) do
print(k .. " = ", v)
end
end
elseif (method == "simple") then
for k, v in pairs(t) do
print(k .. " = ", v)
end
else
print(hs.inspect(t))
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment