Last active
December 26, 2024 20:25
-
-
Save jikanter/4b455f57c1392f85723f3a5ed4d3b78f to your computer and use it in GitHub Desktop.
[Inspect Table] #hammerspoon #lua
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -- 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