# Table  `[Shared]`

The Table module extends Lua's native table capabilities by adding powerful utility functions for enhanced table manipulation.

## Table Functions

### table.addMultiLevels()

A function to add a multiples table levels inside a variable if it not exists <br>

#### Syntax

```lua
table.addMultiLevels(...)
```

#### Parameters

`...` : _table|string_
> if the 1st argument is a table, keys will be injected in it. Else, a new table will be created
>

#### Return Value

Type : _table_

> The new table with multiples table levels

---

### table.clearForNui()

Returns a copy of the table with all function values removed. <br>

#### Syntax

```lua
table.clearForNui(t)
```

#### Parameters

`t` : _table_

> The table to clean
>

#### Return Value

Type : _table_

> The table without function values

---

### table.copy()

Deep copies a table. Unlike "=", it doesn't keep the link between both tables. <br>

#### Syntax

```lua
table.copy(t)
```

#### Parameters

`t` : _table_

> The table you want to copy
>

#### Return Value

Type : _table_

> The copy of the table

---

### table.count()

Counts the number of values inside a table. <br>

#### Syntax

```lua
table.count(t)
```

#### Parameters

`t` : _table_

> The table to count elements in
>

#### Return Value

Type : _integer_

> The number of values inside the table

---

### table.deleteAndClear()

A function to delete a deep value in a table and clear the table if it's empty <br>

#### Syntax

```lua
table.deleteAndClear(t, keys)
```

#### Parameters

`t` : _table_

> The table
>

`keys` : _any_
> The keys to deep
>

#### Return Value

Type : _boolean_

> Returns `true` if the value was deleted

---

### table.deleteDeepValue()

A function to delete a deep value in a table <br>

#### Syntax

```lua
table.deleteDeepValue(t, keys)
```

#### Parameters

`t` : _table_

> The table
>

`keys` : _any_
> The keys to deep
>

#### Return Value

Type : _table,_

---

### table.doesKeyExist()

A function to know if a deep key exists in a table <br>

#### Syntax

```lua
table.doesKeyExist(t, ...)
```

#### Parameters

`t` : _table_

> The table to check
>

`...` : _string_
> The list of keys to deep
>

#### Return Value

Type : _boolean,_

---

### table.extract()

Extracts a value from a table by key and removes that key from the table. <br>

#### Syntax

```lua
table.extract(t, key)
```

#### Parameters

`t` : _table_

> The table to extract from
>

`key` : _any_
> The key to extract
>

#### Return Value

Type : _any_

> The extracted value

---

### table.filter()

Filters a table based on a callback function. <br>

#### Syntax

```lua
table.filter(t, filterIter, keepKeyAssociation)
```

#### Parameters

`t` : _table_

> The table to filter
>

`filterIter` : _function_
> A function to execute for each element in the table. Should return `true` to keep the element. Called with (element, key, originalTable)
>

`keepKeyAssociation` : _boolean_ `[Optional]`
> Keep the original table keys instead of creating a sequential table <br> default:`false`
>

#### Return Value

Type : _table_

> The filtered table

---

### table.find()

Returns the first element in the table that satisfies the provided function. <br>

#### Syntax

```lua
table.find(t, func)
```

#### Parameters

`t` : _table_

> The table to search in
>

`func` : _function_
> A function to test each element. Should return `true` when found. Called with (element, key, originalTable)
>

#### Return Value

Type : _any,any_

> The found value or `false` if not found , The key of the found value

---

### table.getDeep()

A function to get a deep value in a table <br>

#### Syntax

```lua
table.getDeep(t, keys)
```

#### Parameters

`t` : _table_

> The table
>

`keys` : _any_
> The keys to deep
>

#### Return Value

Type : _any,_

---

### table.includes()

A function to search a value inside an array <br>

#### Syntax

```lua
table.includes(t, value, fromIndex)
```

#### Parameters

`t` : _table_

> The table
>

`value` : _any_
> The value to search
>

`fromIndex` : _integer_ `[Optional]`
> index at which to start searching <br> default: `1`
>

#### Return Value

Type : _integer_

> Returns the index of the found value or 0 if missing

---

### table.isEgal()

Compares two tables for equality. <br>

#### Syntax

```lua
table.isEgal(table1, table2, strict, canMissInTable1, canMissInTable2)
```

#### Parameters

`table1` : _table_

> First table to compare
>

`table2` : _table_

> Second table to compare
>

`strict` : _boolean_ `[Optional]`
> If all keys should be in both tables <br> default:`true`
>

`canMissInTable1` : _boolean_ `[Optional]`
> If table2 keys can miss in table1 <br> default:`false`
>

`canMissInTable2` : _boolean_ `[Optional]`
> If table1 keys can miss in table2 <br> default:`false`
>

#### Return Value

Type : _boolean_

> Returns `true` if tables are equal according to specified parameters

---

### table.isEmpty()

Checks if a table is empty. <br>

#### Syntax

```lua
table.isEmpty(t)
```

#### Parameters

`t` : _table_

> The table to check
>

#### Return Value

Type : _boolean_

> Returns true if the table is empty

---

### table.map()

Creates a new table populated with the results of calling a function on every element. <br>

#### Syntax

```lua
table.map(t, func)
```

#### Parameters

`t` : _table_

> The table to map
>

`func` : _function|any_
> A function to transform each element. Called with (element, key, originalTable)
>

#### Return Value

Type : _table_

> The new mapped table

---

### table.merge()

Merges multiple tables together. <br>

#### Syntax

```lua
table.merge(deepMerge, ...)
```

#### Parameters

`deepMerge` : _boolean_ `[Optional]`
> Whether to deep merge tables
>

`...` : _table_

> The tables to merge
>

#### Return Value

Type : _table_

> The merged table. If the same key exists in both tables, only the value of t2 is kept

---

### table.mergeAfter()

Merges the values of the second table sequentially into the first table. <br>

#### Syntax

```lua
table.mergeAfter(...)
```

#### Parameters

`...` : _table_

> The tables to merge
>

#### Return Value

Type : _table_

> The merged table with values from t2 added at the end of t1

---

### table.slice()

Get a part of table with stard and end index <br>

#### Syntax

```lua
table.slice(t, s, e)
```

#### Parameters

`t` : _table_

> The table to get from
>

`s` : _integer_ `[Optional]`
> The start intex <br> default:`1`
>

`e` : _integer_ `[Optional]`
> The end index <br> default:`s`
>

#### Return Value

Type : _table_

> The extracted table

---

### table.upsert()

A function to set/update a value in a table with multiple levels <br>

#### Syntax

```lua
table.upsert(...)
```

#### Parameters

`...` : _table|string_
> if the 1st argument is a table, keys will be injected in it. Else, a new table will be created. The last argument is the value to set
>

#### Return Value

Type : _table_

> The new table with multiples table levels
