Call as
Functions.collections.deepcopy(array, except, invert)
Record it as a dependency named Functions.collections.deepcopy (accepting the completion does this), then call it by that name.
What it does
Create a shallow filtered copy despite the historical deepcopy name. Nested values retain their original identities and the source metatable is not copied. By default exclude keys listed among except values; invert true includes only listed keys. Nil input returns nil.
Arguments
| Name | Type | What it does |
|---|---|---|
array | table | nil | Table to copy shallowly, or nil. |
except | table | nil | Optional collection of key values selecting entries; its own keys are ignored. |
invert | boolean | nil | True includes only listed entries; false or nil excludes listed entries. |
Returns
| 1 | table | nil | New shallow filtered table, or nil for nil input. |
|---|
Editions
Built In helpers are registered on every edition. What differs is the game API they read; where one is missing the helper falls back or returns nil with a reason.
It reads no game API directly.
How the addon calls it
- Attackable (widget)
local unit = addon:Widget_UnitWidget(value, Functions.collections.deepcopy(addon.units, { "player", "pet" }), - Cast Interruptible (widget)
local unit = addon:Widget_UnitWidget(value, Functions.collections.deepcopy(addon.units, { "player", "pet" }), - Channel Interruptible (widget)
local unit = addon:Widget_UnitWidget(value, Functions.collections.deepcopy(addon.units, { "player", "pet" }), - Class (widget)
local unit = addon:Widget_UnitWidget(value, Functions.collections.deepcopy(addon.units, { "player", "pet" }), - Unit Classification (widget)
local unit = addon:Widget_UnitWidget(value, Functions.collections.deepcopy(addon.units, { "player", "pet" }), - Combat Action History (widget)
local unit = addon:Widget_UnitWidget(value, Functions.collections.deepcopy(addon.units, { "player", "pet", "target" }, true), - Combat Action History Time (widget)
local unit = addon:Widget_UnitWidget(value, Functions.collections.deepcopy(addon.units, { "player", "pet", "target" }, true), - Creature Type (widget)
local unit = addon:Widget_UnitWidget(value, Functions.collections.deepcopy(addon.units, { "player", "pet" }),
and 12 more: Hostile (widget), In Group (widget), Immune (widget), Is Same As (widget), PVP Flagged (widget), Resistant (widget), Role (widget), Runner (widget), Character Stat (widget), Has Stealable Buff (widget), Threat (widget), Zone PVP (widget)
Source
Functions/collections.lua, line 141. Read only in game; Duplicate makes an editable copy.
Functions.collections.deepcopy(array, except, invert)
if array == nil then
return nil
end
if invert == nil then
invert = false
end
local rv = {}
for k,v in pairs(array) do
local skip = invert
if except ~= nil then
for _,v2 in pairs(except) do
if (k == v2) then
skip = not invert
break
end
end
end
if not skip then
rv[k] = v
end
end
return rv