> For the complete documentation index, see [llms.txt](https://laot7490.gitbook.io/ltbridge/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://laot7490.gitbook.io/ltbridge/utilities/table.md).

# Table

## Table

Table helpers — merge, filter, map, deep copy, and more.

### Functions

<table data-view="cards"><thead><tr><th></th><th></th><th data-hidden data-card-target data-type="content-ref"></th></tr></thead><tbody><tr><td><strong>Contains</strong></td><td>Check if a table contains a value.</td><td><a href="#contains">#contains</a></td></tr><tr><td><strong>DeepCopy</strong></td><td>Deep copy a table recursively.</td><td><a href="#deepcopy">#deepcopy</a></td></tr><tr><td><strong>Filter</strong></td><td>Filter a table by a predicate function.</td><td><a href="#filter">#filter</a></td></tr><tr><td><strong>Keys</strong></td><td>Get all keys of a table.</td><td><a href="#keys">#keys</a></td></tr><tr><td><strong>Map</strong></td><td>Map a table by a transform function.</td><td><a href="#map">#map</a></td></tr><tr><td><strong>Merge</strong></td><td>Merge two tables. Override values take priority.</td><td><a href="#merge">#merge</a></td></tr><tr><td><strong>Size</strong></td><td>Get size of a table (works for non-sequential tables by default).</td><td><a href="#size">#size</a></td></tr><tr><td><strong>Values</strong></td><td>Get all values of a table.</td><td><a href="#values">#values</a></td></tr></tbody></table>

***

## Contains

Check if a table contains a value.

{% hint style="info" %}
**Side:** Shared · **Category:** Table · **API:** `LT.Table.Contains`
{% endhint %}

### Example

```lua
local found = LT.Table.Contains({1, 2, 3}, 2)
-- true
```

### Parameters

| Name    | Required | Description |
| ------- | -------- | ----------- |
| `tbl`   | Yes      | table       |
| `value` | Yes      | any         |
| `iter`  | No       | boolean     |

### Returns

* `boolean`

***

## DeepCopy

Deep copy a table recursively.

{% hint style="info" %}
**Side:** Shared · **Category:** Table · **API:** `LT.Table.DeepCopy`
{% endhint %}

### Example

```lua
local copy = LT.Table.DeepCopy({ a = 1, b = { c = 2 } })
```

### Parameters

| Name   | Required | Description |
| ------ | -------- | ----------- |
| `tbl`  | Yes      | table       |
| `iter` | No       | boolean     |

### Returns

* `table`

***

## Filter

Filter a table by a predicate function.

{% hint style="info" %}
**Side:** Shared · **Category:** Table · **API:** `LT.Table.Filter`
{% endhint %}

### Example

```lua
local evens = LT.Table.Filter({1, 2, 3, 4}, function(v) return v % 2 == 0 end)
-- {2, 4}
```

### Parameters

| Name        | Required | Description                        |
| ----------- | -------- | ---------------------------------- |
| `tbl`       | Yes      | table                              |
| `predicate` | Yes      | fun(value: any, key: any): boolean |
| `iter`      | No       | boolean                            |

### Returns

* `table`

***

## Keys

Get all keys of a table.

{% hint style="info" %}
**Side:** Shared · **Category:** Table · **API:** `LT.Table.Keys`
{% endhint %}

### Example

```lua
local keys = LT.Table.Keys({ foo = 1, bar = 2 })
-- { 'foo', 'bar' }
```

### Parameters

| Name   | Required | Description |
| ------ | -------- | ----------- |
| `tbl`  | Yes      | table       |
| `iter` | No       | boolean     |

### Returns

* `table`

***

## Map

Map a table by a transform function.

{% hint style="info" %}
**Side:** Shared · **Category:** Table · **API:** `LT.Table.Map`
{% endhint %}

### Example

```lua
local doubled = LT.Table.Map({1, 2, 3}, function(v) return v * 2 end)
-- {2, 4, 6}
```

### Parameters

| Name        | Required | Description                    |
| ----------- | -------- | ------------------------------ |
| `tbl`       | Yes      | table                          |
| `transform` | Yes      | fun(value: any, key: any): any |
| `iter`      | No       | boolean                        |

### Returns

* `table`

***

## Merge

Merge two tables. Nested tables are merged recursively; override values take priority.

{% hint style="info" %}
**Side:** Shared · **Category:** Table · **API:** `LT.Table.Merge`
{% endhint %}

### Example

```lua
local merged = LT.Table.Merge({ a = 1, nested = { x = 1 } }, { b = 2, nested = { y = 2 } })
-- { a = 1, b = 2, nested = { x = 1, y = 2 } }
```

### Parameters

| Name       | Required | Description |
| ---------- | -------- | ----------- |
| `base`     | Yes      | table       |
| `override` | Yes      | table       |
| `iter`     | No       | boolean     |

### Returns

* `table`

***

## Size

Get size of a table (works for non-sequential tables by default).

{% hint style="info" %}
**Side:** Shared · **Category:** Table · **API:** `LT.Table.Size`
{% endhint %}

### Example

```lua
local count = LT.Table.Size({ a = 1, b = 2, c = 3 })
-- 3
```

### Parameters

| Name   | Required | Description |
| ------ | -------- | ----------- |
| `tbl`  | Yes      | table       |
| `iter` | No       | boolean     |

### Returns

* `number`

***

## Values

Get all values of a table.

{% hint style="info" %}
**Side:** Shared · **Category:** Table · **API:** `LT.Table.Values`
{% endhint %}

### Example

```lua
local vals = LT.Table.Values({ foo = 1, bar = 2 })
-- { 1, 2 }
```

### Parameters

| Name   | Required | Description |
| ------ | -------- | ----------- |
| `tbl`  | Yes      | table       |
| `iter` | No       | boolean     |

### Returns

* `table`
