Skip to main content

Table

Provide a variety of utility table operations

Functions​

append​

Table.append(
target: table,--

Table to append to

source: table--

Table read from

) → table--

parameter table

Concats target with source in-place, modifying the target

merge​

Table.merge(
orig: table,--

Original table

new: table--

Result

) → table

Shallow merges two tables without modifying either.

reverse​

Table.reverse(
orig: table--

Original table

) → table

Reverses the list and returns the reversed copy

values​

Table.values(
source: table--

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(
source: table--

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(
orig: table,--

Original table

new: table--

Result

) → table

Shallow merges two lists without modifying either.

swapKeyValue​

Table.swapKeyValue(
orig: table--

Original table

) → table

Swaps keys with values, overwriting additional values if duplicated.

toList​

Table.toList(
_table: table--

Table to convert to a list

) → table

Converts a table to a list.

count​

Table.count(
_table: table--

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(
target: table--

Table to copy

) → table--

Result

Shallow copies a table from target into a new table

deepCopy​

Table.deepCopy(
target: table,--

Table to deep copy

_deepCopyContext: table?--

Context to deepCopy the value in

) → table--

Result

Deep copies a table including metatables

deepOverwrite​

Table.deepOverwrite(
target: table,--

Target table

source: table--

Table to read from

) → table--

target

Overwrites a table's value

getIndex​

Table.getIndex(
haystack: table,--

To search in

needle: Valuetosearchfor
) → (
Theindexofthevalue,iffound,
nil--

if not found

)

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

stringify​

Table.stringify(
_table: table,--

Table to stringify

indent: number?,--

Indent level

output: string?--

Output string, used recursively

) → string--

The table in string form

Recursively prints the table. Does not handle recursive tables.

contains​

Table.contains(
_table: table,--

To search in for value

value: any--

Value to search for

) → boolean--

true if within, false otherwise

Returns whether value is within table

overwrite​

Table.overwrite(
target: table,--

Table to overwite

source: table--

Source table to read from

) → table--

target

Overwrites an existing table with the source values.

deepEquivalent​

Table.deepEquivalent(
target: table,--

Table to check

source: table--

Other table to check

) → boolean

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

take​

Table.take(
source: table,--

Source table to retrieve values from

count: number--

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(
target: table--

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

errorOnNilIndex​

Table.errorOnNilIndex(
target: table--

Table to error on indexing

) → table--

The same table, with the target set to error on nil

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

deepReadonly​

Table.deepReadonly(
target: table--

Table to error on indexing

) → table--

The same table

Recursively sets the table as ReadOnly

reduce​

Table.reduce(
target: table,--

Table to reduce

reducer: function,--

Reducer function

initial: any--

Initial value

) → any--

Result

Reduces a table into a single value.

Show raw api
{
    "functions": [
        {
            "name": "append",
            "desc": "Concats `target` with `source` in-place, modifying the target",
            "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": 19,
                "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": 34,
                "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": 48,
                "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": 62,
                "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": 76,
                "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": 91,
                "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": 108,
                "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": 122,
                "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": 137,
                "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": 153,
                "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": "_deepCopyContext",
                    "desc": "Context to deepCopy the value in",
                    "lua_type": "table?"
                }
            ],
            "returns": [
                {
                    "desc": "Result",
                    "lua_type": "table"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 162,
                "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": 186,
                "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": 204,
                "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": 224,
                "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": 246,
                "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": 263,
                "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": 278,
                "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": 316,
                "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": 343,
                "path": "src/table/src/Shared/Table.lua"
            }
        },
        {
            "name": "errorOnNilIndex",
            "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 target set to error on nil",
                    "lua_type": "table"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 354,
                "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": 364,
                "path": "src/table/src/Shared/Table.lua"
            }
        },
        {
            "name": "reduce",
            "desc": "Reduces a table into a single value.",
            "params": [
                {
                    "name": "target",
                    "desc": "Table to reduce",
                    "lua_type": "table"
                },
                {
                    "name": "reducer",
                    "desc": "Reducer function",
                    "lua_type": "function"
                },
                {
                    "name": "initial",
                    "desc": "Initial value",
                    "lua_type": "any"
                }
            ],
            "returns": [
                {
                    "desc": "Result",
                    "lua_type": "any"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 382,
                "path": "src/table/src/Shared/Table.lua"
            }
        }
    ],
    "properties": [],
    "types": [],
    "name": "Table",
    "desc": "Provide a variety of utility table operations",
    "source": {
        "line": 6,
        "path": "src/table/src/Shared/Table.lua"
    }
}