Syntax
filtergc(filterType: string, options: table, returnOne?: boolean): table | function | nilArguments
| Name | Type | Description |
|---|---|---|
filterType | string | GC object type to search. The value is lowercased and must be "table" or "function". |
options | table | Filter table. Function searches read Name, Hash, StartLine, IgnoreExecutor, IgnoreSyn, Environment, Constants, and Upvalues. Table searches read Metatable, Keys, Values, and KeyValuePairs. |
returnOne? | boolean | Optional optional boolean handling flag. When true, returns the first matching object or nil instead of an array table. |
Returns
| Name | Type | Description |
|---|---|---|
result | table | function | nil | When returnOne is false or omitted, an array table of matches. When returnOne is true, the first matching table/function object or nil. |
Description
Searches live garbage-collected tables or functions that match the supplied filters. filterType must be "table" or "function". options must be a table.
Call it with 3 parameter(s): filterType, options, returnOne. The argument table explains which values are required and which ones only refine the behavior.
It returns result (table | function | nil). Use the returns table to separate successful values from nil results and recoverable errors.
Example
Find GC tables by key filters without relying on result order.
local marker = {
RealDocsMarker = true,
}
local matches = filtergc("table", {
Keys = { "RealDocsMarker" },
})
for _, value in ipairs(matches) do
if value == marker then
print("found marker")
break
end
end
local first = filtergc("table", {
Keys = { "RealDocsMarker" },
}, true)
print(first ~= nil)