Skip to main content

Table

Provide a variety of utility table operations

Functions

append

Table.append(
targettable,--

Table to append to

sourcetable--

Table read from

) → table--

parameter table

Concats target with source.

merge

Table.merge(
origtable,--

Original table

newtable--

Result

) → table

Shallow merges two tables without modifying either.

reverse

Table.reverse(
origtable--

Original table

) → table

Reverses the list and returns the reversed copy

values

Table.values(
sourcetable--

Table source to extract values from

) → table--

A list with all the values the table has

Returns a list of all of the values that a table has.

keys

Table.keys(
sourcetable--

Table source to extract keys from

) → table--

A list with all the keys the table has

Returns a list of all of the keys that a table has. (In order of pairs)

mergeLists

Table.mergeLists(
origtable,--

Original table

newtable--

Result

) → table

Shallow merges two lists without modifying either.

swapKeyValue

Table.swapKeyValue(
origtable--

Original table

) → table

Swaps keys with values, overwriting additional values if duplicated.

toList

Table.toList(
_tabletable--

Table to convert to a list

) → table

Converts a table to a list.

count

Table.count(
_tabletable--

Table to count

) → number--

count

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

Table.copy

Table.Table.copy(
targettable--

Table to copy

) → table--

Result

Shallow copies a table from target into a new table

deepCopy

Table.deepCopy(
targettable,--

Table to deep copy

_contexttable?--

Context to deepCopy the value in

) → table--

Result

Deep copies a table including metatables

deepOverwrite

Table.deepOverwrite(
targettable,--

Target table

sourcetable--

Table to read from

) → table--

target

Overwrites a table's value

getIndex

Table.getIndex(
haystacktable,--

To search in

needleValuetosearchfor
) → (
Theindexofthevalue,iffound,
nil--

if not found

)

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

stringify

Table.stringify(
_tabletable,--

Table to stringify

indentnumber?,--

Indent level

outputstring?--

Output string, used recursively

) → string--

The table in string form

Recursively prints the table. Does not handle recursive tables.

contains

Table.contains(
_tabletable,--

To search in for value

valueany--

Value to search for

) → boolean--

true if within, false otherwise

Returns whether value is within table

overwrite

Table.overwrite(
targettable,--

Table to overwite

sourcetable--

Source table to read from

) → table--

target

Overwrites an existing table with the source values.

deepEquivalent

Table.deepEquivalent(
targettable,--

Table to check

sourcetable--

Other table to check

) → boolean

Deep equivalent comparison of a table assuming keys are indexable in the same way.

take

Table.take(
sourcetable,--

Source table to retrieve values from

countnumber--

Number of entries to take

) → table--

List with the entries retrieved

Takes count entries from the table. If the table does not have that many entries, will return up to the number the table has to provide.

readonly

Table.readonly(
targettable--

Table to error on indexing

) → table--

The same table, with the metatable set to readonly

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

deepReadonly

Table.deepReadonly(
targettable--

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": "parameter table",
                    "lua_type": "table"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 15,
                "path": "src/table/src/Shared/Table.lua"
            }
        },
        {
            "name": "merge",
            "desc": "Shallow merges two tables without modifying either.",
            "params": [
                {
                    "name": "orig",
                    "desc": "Original table",
                    "lua_type": "table"
                },
                {
                    "name": "new",
                    "desc": "Result",
                    "lua_type": "table"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "table"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 30,
                "path": "src/table/src/Shared/Table.lua"
            }
        },
        {
            "name": "reverse",
            "desc": "Reverses the list and returns the reversed copy",
            "params": [
                {
                    "name": "orig",
                    "desc": "Original table",
                    "lua_type": "table"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "table"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 44,
                "path": "src/table/src/Shared/Table.lua"
            }
        },
        {
            "name": "values",
            "desc": "Returns a list of all of the values that a table has.",
            "params": [
                {
                    "name": "source",
                    "desc": "Table source to extract values from",
                    "lua_type": "table"
                }
            ],
            "returns": [
                {
                    "desc": "A list with all the values the table has",
                    "lua_type": "table"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 58,
                "path": "src/table/src/Shared/Table.lua"
            }
        },
        {
            "name": "keys",
            "desc": "Returns a list of all of the keys that a table has. (In order of pairs)",
            "params": [
                {
                    "name": "source",
                    "desc": "Table source to extract keys from",
                    "lua_type": "table"
                }
            ],
            "returns": [
                {
                    "desc": "A list with all the keys the table has",
                    "lua_type": "table"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 72,
                "path": "src/table/src/Shared/Table.lua"
            }
        },
        {
            "name": "mergeLists",
            "desc": "Shallow merges two lists without modifying either.",
            "params": [
                {
                    "name": "orig",
                    "desc": "Original table",
                    "lua_type": "table"
                },
                {
                    "name": "new",
                    "desc": "Result",
                    "lua_type": "table"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "table"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 87,
                "path": "src/table/src/Shared/Table.lua"
            }
        },
        {
            "name": "swapKeyValue",
            "desc": "Swaps keys with 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": 104,
                "path": "src/table/src/Shared/Table.lua"
            }
        },
        {
            "name": "toList",
            "desc": "Converts a table to a list.",
            "params": [
                {
                    "name": "_table",
                    "desc": "Table to convert to a list",
                    "lua_type": "table"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "table"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 118,
                "path": "src/table/src/Shared/Table.lua"
            }
        },
        {
            "name": "count",
            "desc": "Counts the number of items in `_table`.\nUseful since `__len` on table in Lua 5.2 returns just the array length.",
            "params": [
                {
                    "name": "_table",
                    "desc": "Table to count",
                    "lua_type": "table"
                }
            ],
            "returns": [
                {
                    "desc": "count",
                    "lua_type": "number"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 133,
                "path": "src/table/src/Shared/Table.lua"
            }
        },
        {
            "name": "Table.copy",
            "desc": "Shallow copies a table from target into a new table",
            "params": [
                {
                    "name": "target",
                    "desc": "Table to copy",
                    "lua_type": "table"
                }
            ],
            "returns": [
                {
                    "desc": "Result",
                    "lua_type": "table"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 149,
                "path": "src/table/src/Shared/Table.lua"
            }
        },
        {
            "name": "deepCopy",
            "desc": "Deep copies a table including metatables",
            "params": [
                {
                    "name": "target",
                    "desc": "Table to deep copy",
                    "lua_type": "table"
                },
                {
                    "name": "_context",
                    "desc": "Context to deepCopy the value in",
                    "lua_type": "table?"
                }
            ],
            "returns": [
                {
                    "desc": "Result",
                    "lua_type": "table"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 158,
                "path": "src/table/src/Shared/Table.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": 182,
                "path": "src/table/src/Shared/Table.lua"
            }
        },
        {
            "name": "getIndex",
            "desc": "Gets an index by value, returning `nil` if no index is found.",
            "params": [
                {
                    "name": "haystack",
                    "desc": "To search in",
                    "lua_type": "table"
                },
                {
                    "name": "needle",
                    "desc": "",
                    "lua_type": "Value to search for"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "The index of the value, if found"
                },
                {
                    "desc": "if not found",
                    "lua_type": "nil"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 200,
                "path": "src/table/src/Shared/Table.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": "The table in string form",
                    "lua_type": "string"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 219,
                "path": "src/table/src/Shared/Table.lua"
            }
        },
        {
            "name": "contains",
            "desc": "Returns whether `value` is within `table`",
            "params": [
                {
                    "name": "_table",
                    "desc": "To search in for value",
                    "lua_type": "table"
                },
                {
                    "name": "value",
                    "desc": "Value to search for",
                    "lua_type": "any"
                }
            ],
            "returns": [
                {
                    "desc": "`true` if within, `false` otherwise",
                    "lua_type": "boolean"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 241,
                "path": "src/table/src/Shared/Table.lua"
            }
        },
        {
            "name": "overwrite",
            "desc": "Overwrites an existing table with the source values.",
            "params": [
                {
                    "name": "target",
                    "desc": "Table to overwite",
                    "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": 258,
                "path": "src/table/src/Shared/Table.lua"
            }
        },
        {
            "name": "deepEquivalent",
            "desc": "Deep equivalent comparison of a table assuming keys are indexable in the same way.",
            "params": [
                {
                    "name": "target",
                    "desc": "Table to check",
                    "lua_type": "table"
                },
                {
                    "name": "source",
                    "desc": "Other table to check",
                    "lua_type": "table"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "boolean"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 273,
                "path": "src/table/src/Shared/Table.lua"
            }
        },
        {
            "name": "take",
            "desc": "Takes `count` entries from the table. If the table does not have\nthat many entries, will return up to the number the table has to\nprovide.",
            "params": [
                {
                    "name": "source",
                    "desc": "Source table to retrieve values from",
                    "lua_type": "table"
                },
                {
                    "name": "count",
                    "desc": "Number of entries to take",
                    "lua_type": "number"
                }
            ],
            "returns": [
                {
                    "desc": "List with the entries retrieved",
                    "lua_type": "table"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 311,
                "path": "src/table/src/Shared/Table.lua"
            }
        },
        {
            "name": "readonly",
            "desc": "Sets a metatable on a table such that it errors when\nindexing a nil value",
            "params": [
                {
                    "name": "target",
                    "desc": "Table to error on indexing",
                    "lua_type": "table"
                }
            ],
            "returns": [
                {
                    "desc": "The same table, with the metatable set to readonly",
                    "lua_type": "table"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 335,
                "path": "src/table/src/Shared/Table.lua"
            }
        },
        {
            "name": "deepReadonly",
            "desc": "Recursively sets the table as ReadOnly",
            "params": [
                {
                    "name": "target",
                    "desc": "Table to error on indexing",
                    "lua_type": "table"
                }
            ],
            "returns": [
                {
                    "desc": "The same table",
                    "lua_type": "table"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 345,
                "path": "src/table/src/Shared/Table.lua"
            }
        }
    ],
    "properties": [],
    "types": [],
    "name": "Table",
    "desc": "Provide a variety of utility table operations",
    "source": {
        "line": 5,
        "path": "src/table/src/Shared/Table.lua"
    }
}