Skip to main content

TableUtil

Provides a variety of utility Table operations Taken from Nevermore Framework:

Edited by TheEpicTwin

Functions

append

TableUtil.append(
targettable,--

Table to append to

sourcetable--

Table read from

) → tableparametertable

Concats target with source

merge

TableUtil.merge(
origtable,--

original table

newtable--

new table

) → table

Shallow merges two tables without modifying either

mergeLists

TableUtil.mergeLists(
origtable,--

original table

newtable--

new table

) → table

Shallow merges two lists without modifying either

swapKeyValue

TableUtil.swapKeyValue(
origtable--

original table

) → table

Swaps keys with v values, overwriting additional values if duplicated

toList

TableUtil.toList(
tabtable--

Table to convert to a list

) → table

Converts a table to a list

count

TableUtil.count(
tabtable--

Table to count

) → number--

count

Counts the number of items in tab. Useful since __len on table in Lua 5.2 returns just the array length.

copy

TableUtil.copy(targettableTabletocopy) → table--

New table

Copies a table, but not deep.

deepCopy

TableUtil.deepCopy(
targettable--

Table to deep copy

) → table--

New table

Deep copies a table including metatables

deepOverwrite

TableUtil.deepOverwrite(
targettable,--

Target table

sourcetable--

Table to read from

) → table--

target

Overwrites a table's value

getIndex

TableUtil.getIndex(
haystacktable,--

table to search in

needleany--

Value to search for

) → number | nil--

The index of the value, if found. Else nil.

Gets an index by value, returning nil if no index is found.

stringify

TableUtil.stringify(
tabletable,--

Table to stringify

indentnumber,--

Indent level

outputstring--

Output string, used recursively

) → stringThetableinstringform

Recursively prints the table. Does not handle recursive tables.

contains

TableUtil.contains(
tabletable,--

table to search in for value

valueany--

value to search for

) → boolean`true`ifwithin,`false`otherwise

Returns whether value is within table

overwrite

TableUtil.overwrite(
targettable,--

Table to overwrite

sourcetable--

Source table to read from

) → table--

target

Overwrites an existing table

readOnly

TableUtil.readOnly(
tabletable--

Table to error on indexing

) → table--

The same table

Sets a metatable on a table such that it errors when indexing a nil value

deepReadOnly

TableUtil.deepReadOnly(
tabletable--

Table to error on indexing

) → table--

The same table

Recursively sets the table as ReadOnly

Show raw api
{
    "functions": [
        {
            "name": "append",
            "desc": "Concats `target` with `source`",
            "params": [
                {
                    "name": "target",
                    "desc": "Table to append to",
                    "lua_type": "table"
                },
                {
                    "name": "source",
                    "desc": "Table read from",
                    "lua_type": "table"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "table parameter table"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 18,
                "path": "src/shared/modules/tableUtil.lua"
            }
        },
        {
            "name": "merge",
            "desc": "Shallow merges two tables without modifying either",
            "params": [
                {
                    "name": "orig",
                    "desc": "original table",
                    "lua_type": "table"
                },
                {
                    "name": "new",
                    "desc": "new table",
                    "lua_type": "table"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "table"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 32,
                "path": "src/shared/modules/tableUtil.lua"
            }
        },
        {
            "name": "mergeLists",
            "desc": "Shallow merges two lists without modifying either",
            "params": [
                {
                    "name": "orig",
                    "desc": "original table",
                    "lua_type": "table"
                },
                {
                    "name": "new",
                    "desc": "new table",
                    "lua_type": "table"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "table"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 49,
                "path": "src/shared/modules/tableUtil.lua"
            }
        },
        {
            "name": "swapKeyValue",
            "desc": "Swaps keys with v values, overwriting additional values if duplicated",
            "params": [
                {
                    "name": "orig",
                    "desc": "original table",
                    "lua_type": "table"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "table"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 65,
                "path": "src/shared/modules/tableUtil.lua"
            }
        },
        {
            "name": "toList",
            "desc": "Converts a table to a list",
            "params": [
                {
                    "name": "tab",
                    "desc": "Table to convert to a list",
                    "lua_type": "table"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "table"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 78,
                "path": "src/shared/modules/tableUtil.lua"
            }
        },
        {
            "name": "count",
            "desc": "Counts the number of items in `tab`.\nUseful since `__len` on table in Lua 5.2 returns just the array length.",
            "params": [
                {
                    "name": "tab",
                    "desc": "Table to count",
                    "lua_type": "table"
                }
            ],
            "returns": [
                {
                    "desc": "count",
                    "lua_type": "number"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 92,
                "path": "src/shared/modules/tableUtil.lua"
            }
        },
        {
            "name": "copy",
            "desc": "Copies a table, but not deep.",
            "params": [
                {
                    "name": "target",
                    "desc": "",
                    "lua_type": "table Table to copy"
                }
            ],
            "returns": [
                {
                    "desc": "New table",
                    "lua_type": "table"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 105,
                "path": "src/shared/modules/tableUtil.lua"
            }
        },
        {
            "name": "deepCopy",
            "desc": "Deep copies a table including metatables",
            "params": [
                {
                    "name": "target",
                    "desc": "Table to deep copy",
                    "lua_type": "table"
                }
            ],
            "returns": [
                {
                    "desc": "New table",
                    "lua_type": "table"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 118,
                "path": "src/shared/modules/tableUtil.lua"
            }
        },
        {
            "name": "deepOverwrite",
            "desc": "Overwrites a table's value",
            "params": [
                {
                    "name": "target",
                    "desc": "Target table",
                    "lua_type": "table"
                },
                {
                    "name": "source",
                    "desc": "Table to read from",
                    "lua_type": "table"
                }
            ],
            "returns": [
                {
                    "desc": "target",
                    "lua_type": "table"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 143,
                "path": "src/shared/modules/tableUtil.lua"
            }
        },
        {
            "name": "getIndex",
            "desc": "Gets an index by value, returning `nil` if no index is found.",
            "params": [
                {
                    "name": "haystack",
                    "desc": "table to search in",
                    "lua_type": "table"
                },
                {
                    "name": "needle",
                    "desc": "Value to search for",
                    "lua_type": "any"
                }
            ],
            "returns": [
                {
                    "desc": "The index of the value, if found. Else nil.",
                    "lua_type": "number | nil"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 161,
                "path": "src/shared/modules/tableUtil.lua"
            }
        },
        {
            "name": "stringify",
            "desc": "Recursively prints the table. Does not handle recursive tables.",
            "params": [
                {
                    "name": "table",
                    "desc": "Table to stringify",
                    "lua_type": "table"
                },
                {
                    "name": "indent",
                    "desc": "Indent level",
                    "lua_type": "number"
                },
                {
                    "name": "output",
                    "desc": "Output string, used recursively",
                    "lua_type": "string"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "string The table in string form"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 177,
                "path": "src/shared/modules/tableUtil.lua"
            }
        },
        {
            "name": "contains",
            "desc": "Returns whether `value` is within `table`",
            "params": [
                {
                    "name": "table",
                    "desc": "table to search in for value",
                    "lua_type": "table"
                },
                {
                    "name": "value",
                    "desc": "value to search for",
                    "lua_type": "any"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "boolean `true` if within, `false` otherwise"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 199,
                "path": "src/shared/modules/tableUtil.lua"
            }
        },
        {
            "name": "overwrite",
            "desc": "Overwrites an existing table",
            "params": [
                {
                    "name": "target",
                    "desc": "Table to overwrite",
                    "lua_type": "table"
                },
                {
                    "name": "source",
                    "desc": "Source table to read from",
                    "lua_type": "table"
                }
            ],
            "returns": [
                {
                    "desc": "target",
                    "lua_type": "table"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 215,
                "path": "src/shared/modules/tableUtil.lua"
            }
        },
        {
            "name": "readOnly",
            "desc": "Sets a metatable on a table such that it errors when\nindexing a nil value",
            "params": [
                {
                    "name": "table",
                    "desc": "Table to error on indexing",
                    "lua_type": "table"
                }
            ],
            "returns": [
                {
                    "desc": "The same table",
                    "lua_type": "table"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 229,
                "path": "src/shared/modules/tableUtil.lua"
            }
        },
        {
            "name": "deepReadOnly",
            "desc": "Recursively sets the table as ReadOnly",
            "params": [
                {
                    "name": "table",
                    "desc": "Table to error on indexing",
                    "lua_type": "table"
                }
            ],
            "returns": [
                {
                    "desc": "The same table",
                    "lua_type": "table"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 245,
                "path": "src/shared/modules/tableUtil.lua"
            }
        }
    ],
    "properties": [],
    "types": [],
    "name": "TableUtil",
    "desc": "Provides a variety of utility Table operations\nTaken from Nevermore Framework:\n- https://github.com/Quenty/NevermoreEngine/blob/version2/Modules/Shared/Utility/Table.lua\n- https://github.com/Quenty/NevermoreEngine\n#### Edited by TheEpicTwin",
    "source": {
        "line": 9,
        "path": "src/shared/modules/tableUtil.lua"
    }
}