Community BridgeLibrariesTable UtilitiesShared

Table Utilities

The Table library provides common table manipulation helpers.

Side: Shared

Functions

DeepCopy

Creates a deep copy of a table, including nested tables.

local copy = Bridge.Tables.DeepCopy(original)
-- Returns: table
ParameterTypeDescription
originaltableTable to copy

Contains

Checks if a table contains a specific value.

local found = Bridge.Tables.Contains(tbl, value)
-- Returns: boolean
ParameterTypeDescription
tbltableTable to search
valueanyValue to find

Count

Returns the number of entries in a table (works for non-sequential tables).

local count = Bridge.Tables.Count(tbl)
-- Returns: number
ParameterTypeDescription
tbltableTable to count

Merge

Merges two tables together. Values from the second table override the first.

local merged = Bridge.Tables.Merge(t1, t2)
-- Returns: table
ParameterTypeDescription
t1tableBase table
t2tableTable to merge in

Keys

Returns an array of all keys in a table.

local keys = Bridge.Tables.Keys(tbl)
-- Returns: table
ParameterTypeDescription
tbltableSource table

Values

Returns an array of all values in a table.

local values = Bridge.Tables.Values(tbl)
-- Returns: table
ParameterTypeDescription
tbltableSource table

Filter

Returns a new table containing only entries that pass a filter function.

local filtered = Bridge.Tables.Filter(tbl, fn)
-- Returns: table
ParameterTypeDescription
tbltableSource table
fnfunctionFilter function (value, key) -> boolean

Map

Returns a new table with each value transformed by a function.

local mapped = Bridge.Tables.Map(tbl, fn)
-- Returns: table
ParameterTypeDescription
tbltableSource table
fnfunctionTransform function (value, key) -> newValue

Find

Returns the first value (and key) that matches a predicate.

local value, key = Bridge.Tables.Find(tbl, fn)
ParameterTypeDescription
tbltableSource table
fnfunctionPredicate function (value, key) -> boolean

Flatten

Flattens a nested table into a single-level table.

local flat = Bridge.Tables.Flatten(tbl)
-- Returns: table
ParameterTypeDescription
tbltableNested table to flatten