Skip to main content

Immutable

A module to contain shared methods that apply to both List (type) and Dictionary (type) immutable objects.

Can also be used to access List and Dictionary classes and methods. See Accessing data methods for more information.

Functions

Draft

thaw
Immutable.Draft(immutableImmutable) → {any} | {[string]any}--

The thawed table.

Returns a primitive table, unfrozen (thawed) at the top level. Nested references to other Immutables will not be thawed.

Used internally when performing operations on Immutables.

Returns an array if the input Immutable was a List, or a dictionary if the input Immutable was a Dictionary.

Thaw

thaw
Immutable.Thaw(immutableImmutable) → {any} | {[string]any}--

The thawed table.

Returns a primitive table, unfrozen (thawed) deeply. All nested references to other Immutables will be thawed.

Returns an array if the input Immutable was a List, or a dictionary if the input Immutable was a Dictionary.

Equals

compare
Immutable.Equals(
immutableAImmutable,
immutableBImmutable
) → boolean

Returns true if the two Immutables are deeply equal by value.

Get

evaluate
Immutable.Get(
immutableImmutable,
keystring | integer,--

The index for a List, or the key for a Dictionary.

defaultany | nil--

The default value to return if the key doesn't exist.

) → any | nil

Returns the value at the specified key or index, or nil if it doesn't exist.

Set

manipulate
Immutable.Set(
immutableImmutable,
keystring | integer,--

The index for a List, or the key for a Dictionary.

valueany--

The value to set.

) → Immutable--

The new Immutable with updated values.

Returns a new Immutable with the new value set at the specified key or index.

If the Immutable is a List, the index must be within the bounds of the List or the next index after the last element.

Update

manipulate
Immutable.Update(
immutableImmutable,
keystring | integer,--

The index for a List, or the key for a Dictionary.

updater(any) → any--

A function that takes the existing value at key and returns a new value to set.

) → Immutable--

The new Immutable with updated values.

Returns a new Immutable with the result of updater[key] set at the specified key or index.

If the Immutable is a List, the index must be within the bounds of the List or the next index after the last element.

Show raw api
{
    "functions": [
        {
            "name": "Draft",
            "desc": "Returns a primitive table, unfrozen (thawed) at the top level.\nNested references to other Immutables will not be thawed.\n\nUsed internally when performing operations on Immutables.\n\nReturns an array if the input Immutable was a List, or a dictionary if the input Immutable was a\nDictionary.",
            "params": [
                {
                    "name": "immutable",
                    "desc": "",
                    "lua_type": "Immutable"
                }
            ],
            "returns": [
                {
                    "desc": "The thawed table.",
                    "lua_type": "{any} | {[string]: any}"
                }
            ],
            "function_type": "static",
            "tags": [
                "thaw"
            ],
            "source": {
                "line": 71,
                "path": "src/init.lua"
            }
        },
        {
            "name": "Thaw",
            "desc": "Returns a primitive table, unfrozen (thawed) deeply.\nAll nested references to other Immutables will be thawed.\n\nReturns an array if the input Immutable was a List, or a dictionary if the input Immutable was a\nDictionary.",
            "params": [
                {
                    "name": "immutable",
                    "desc": "",
                    "lua_type": "Immutable"
                }
            ],
            "returns": [
                {
                    "desc": "The thawed table.",
                    "lua_type": "{any} | {[string]: any}"
                }
            ],
            "function_type": "static",
            "tags": [
                "thaw"
            ],
            "source": {
                "line": 91,
                "path": "src/init.lua"
            }
        },
        {
            "name": "Equals",
            "desc": "Returns true if the two Immutables are deeply equal by value.",
            "params": [
                {
                    "name": "immutableA",
                    "desc": "",
                    "lua_type": "Immutable"
                },
                {
                    "name": "immutableB",
                    "desc": "",
                    "lua_type": "Immutable"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "boolean"
                }
            ],
            "function_type": "static",
            "tags": [
                "compare"
            ],
            "source": {
                "line": 118,
                "path": "src/init.lua"
            }
        },
        {
            "name": "Get",
            "desc": "Returns the value at the specified key or index, or nil if it doesn't exist.",
            "params": [
                {
                    "name": "immutable",
                    "desc": "",
                    "lua_type": "Immutable"
                },
                {
                    "name": "key",
                    "desc": "The index for a List, or the key for a Dictionary.",
                    "lua_type": "string | integer"
                },
                {
                    "name": "default",
                    "desc": "The default value to return if the key doesn't exist.",
                    "lua_type": "any | nil"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "any | nil"
                }
            ],
            "function_type": "static",
            "tags": [
                "evaluate"
            ],
            "source": {
                "line": 161,
                "path": "src/init.lua"
            }
        },
        {
            "name": "Set",
            "desc": "Returns a new Immutable with the new value set at the specified key or index.\n\nIf the Immutable is a List, the index must be within the bounds of the List or the next index\nafter the last element.",
            "params": [
                {
                    "name": "immutable",
                    "desc": "",
                    "lua_type": "Immutable"
                },
                {
                    "name": "key",
                    "desc": "The index for a List, or the key for a Dictionary.",
                    "lua_type": "string | integer"
                },
                {
                    "name": "value",
                    "desc": "The value to set.",
                    "lua_type": "any"
                }
            ],
            "returns": [
                {
                    "desc": "The new Immutable with updated values.",
                    "lua_type": "Immutable"
                }
            ],
            "function_type": "static",
            "tags": [
                "manipulate"
            ],
            "source": {
                "line": 191,
                "path": "src/init.lua"
            }
        },
        {
            "name": "Update",
            "desc": "Returns a new Immutable with the result of updater[key] set at the specified key or index.\n\nIf the Immutable is a List, the index must be within the bounds of the List or the next index\nafter the last element.",
            "params": [
                {
                    "name": "immutable",
                    "desc": "",
                    "lua_type": "Immutable"
                },
                {
                    "name": "key",
                    "desc": "The index for a List, or the key for a Dictionary.",
                    "lua_type": "string | integer"
                },
                {
                    "name": "updater",
                    "desc": "A function that takes the existing value at key and returns a new value to set.",
                    "lua_type": "(any) -> any"
                }
            ],
            "returns": [
                {
                    "desc": "The new Immutable with updated values.",
                    "lua_type": "Immutable"
                }
            ],
            "function_type": "static",
            "tags": [
                "manipulate"
            ],
            "source": {
                "line": 220,
                "path": "src/init.lua"
            }
        }
    ],
    "properties": [],
    "types": [],
    "name": "Immutable",
    "desc": "A module to contain shared methods that apply to both [List] (type) and [Dictionary] (type)\nimmutable objects.\n\nCan also be used to access [List](/api/List) and [Dictionary](/api/Dictionary) classes and\nmethods. See [Accessing data methods](/docs#access-data-methods) for more information.",
    "source": {
        "line": 1851,
        "path": "src/init.lua"
    }
}