Skip to main content

Dictionary

A module containing data methods for evaluating and manipulating a Dictionary — an immutable table of key-value pairs.

Also inherits all shared methods from Immutable.

Functions

Has

evaluate
Dictionary.Has(
dictionaryDictionary,
keystring--

The key to search for.

) → boolean--

True if the Dictionary has the key, otherwise false.

Returns true if the Dictionary has the key, otherwise returns false.

Keys

evaluate
Dictionary.Keys(dictionaryDictionary) → List--

The List of keys.

Returns a List of all the keys in the Dictionary. The List is sorted alphabetically ascending.

Values

evaluate
Dictionary.Values(dictionaryDictionary) → List--

The List of values.

Returns a List of all the values in the Dictionary. The List is sorted alphabetically ascending.

Defaults

manipulate
Dictionary.Defaults(
dictionaryDictionary,
defaultsDictionary | {[string]any}--

The dictionary of default values.

) → Dictionary--

The new Dictionary with default values set.

Returns a new Dictionary with default values set for any keys that don't exist in the original Dictionary. If a key already exists in the original Dictionary, the value will not be changed.

Merge

manipulate
Dictionary.Merge(
firstDictionaryDictionary,
secondDictionaryDictionary | {[string]any}
) → Dictionary--

The new Dictionary with the key-value pairs merged.

Returns a new Dictionary with all the key-value pairs from the second Dictionary merged into the first. If a key exists in both Dictionaries, the value from the second Dictionary will be used.

This function is similar to Defaults, but will overwrite existing values.

Pick

manipulate
Dictionary.Pick(
dictionaryDictionary,
keysList | {string}--

The list of keys to pick.

) → Dictionary--

The new Dictionary with only the picked keys.

Returns a new Dictionary with only the keys specified in the keys. If a key does not exist in the original Dictionary, it will be ignored.

Omit

manipulate
Dictionary.Omit(
dictionaryDictionary,
keysList | {string}--

The list of keys to omit.

) → Dictionary--

The new Dictionary with the omitted keys.

Returns a new Dictionary with all the keys specified in the keys removed. If a key does not exist in the original Dictionary, it will be ignored.

FilterKeys

manipulate
Dictionary.FilterKeys(
dictionaryDictionary,
predicate(string) → boolean--

A function that takes a key returns a boolean.

) → Dictionary--

The new Dictionary with only the keys that pass the predicate.

Returns a new Dictionary with only the keys that pass the predicate.

FilterValues

manipulate
Dictionary.FilterValues(
dictionaryDictionary,
predicate(
any,
string
) → boolean--

A function that takes a value and its key, and returns a boolean.

) → Dictionary--

The new Dictionary with only the values that pass the predicate.

Returns a new Dictionary with only the values that pass the predicate.

Invert

manipulate
Dictionary.Invert(
dictionaryDictionary,
strictboolean | nil--

If true, an error will be thrown if a value is not a string. If false, non-string values will be ignored. Defaults to false.

) → Dictionary--

The new Dictionary with keys and values swapped.

Returns a new Dictionary with keys and values swapped. If there are duplicate values, the last value (when keys are ordered ascending) will be used.

Only Dictionaries with string values can be inverted. If a value is not a string, it will either be ignored or an error will be thrown, depending on the strict parameter.

Unset

manipulate
Dictionary.Unset(
dictionaryDictionary,
keystring--

The key to remove.

) → Dictionary--

The new Dictionary with the key removed.

Returns a new Dictionary with the specified key removed. If the key does not exist in the original Dictionary, the original Dictionary will be returned.

Show raw api
{
    "functions": [
        {
            "name": "Has",
            "desc": "Returns true if the Dictionary has the key, otherwise returns false.",
            "params": [
                {
                    "name": "dictionary",
                    "desc": "",
                    "lua_type": "Dictionary"
                },
                {
                    "name": "key",
                    "desc": "The key to search for.",
                    "lua_type": "string"
                }
            ],
            "returns": [
                {
                    "desc": "True if the Dictionary has the key, otherwise false.",
                    "lua_type": "boolean"
                }
            ],
            "function_type": "static",
            "tags": [
                "evaluate"
            ],
            "source": {
                "line": 1264,
                "path": "src/init.lua"
            }
        },
        {
            "name": "Keys",
            "desc": "Returns a List of all the keys in the Dictionary. The List is sorted alphabetically ascending.",
            "params": [
                {
                    "name": "dictionary",
                    "desc": "",
                    "lua_type": "Dictionary"
                }
            ],
            "returns": [
                {
                    "desc": "The List of keys.",
                    "lua_type": "List"
                }
            ],
            "function_type": "static",
            "tags": [
                "evaluate"
            ],
            "source": {
                "line": 1280,
                "path": "src/init.lua"
            }
        },
        {
            "name": "Values",
            "desc": "Returns a List of all the values in the Dictionary. The List is sorted alphabetically ascending.",
            "params": [
                {
                    "name": "dictionary",
                    "desc": "",
                    "lua_type": "Dictionary"
                }
            ],
            "returns": [
                {
                    "desc": "The List of values.",
                    "lua_type": "List"
                }
            ],
            "function_type": "static",
            "tags": [
                "evaluate"
            ],
            "source": {
                "line": 1304,
                "path": "src/init.lua"
            }
        },
        {
            "name": "Defaults",
            "desc": "Returns a new Dictionary with default values set for any keys that don't exist in the original\nDictionary. If a key already exists in the original Dictionary, the value will not be changed.",
            "params": [
                {
                    "name": "dictionary",
                    "desc": "",
                    "lua_type": "Dictionary"
                },
                {
                    "name": "defaults",
                    "desc": "The dictionary of default values.",
                    "lua_type": "Dictionary | {[string]: any}"
                }
            ],
            "returns": [
                {
                    "desc": "The new Dictionary with default values set.",
                    "lua_type": "Dictionary"
                }
            ],
            "function_type": "static",
            "tags": [
                "manipulate"
            ],
            "source": {
                "line": 1332,
                "path": "src/init.lua"
            }
        },
        {
            "name": "Merge",
            "desc": "Returns a new Dictionary with all the key-value pairs from the second Dictionary merged into the\nfirst. If a key exists in both Dictionaries, the value from the second Dictionary will be used.\n\nThis function is similar to `Defaults`, but will overwrite existing values.",
            "params": [
                {
                    "name": "firstDictionary",
                    "desc": "",
                    "lua_type": "Dictionary"
                },
                {
                    "name": "secondDictionary",
                    "desc": "",
                    "lua_type": "Dictionary | {[string]: any}"
                }
            ],
            "returns": [
                {
                    "desc": "The new Dictionary with the key-value pairs merged.",
                    "lua_type": "Dictionary"
                }
            ],
            "function_type": "static",
            "tags": [
                "manipulate"
            ],
            "source": {
                "line": 1360,
                "path": "src/init.lua"
            }
        },
        {
            "name": "Pick",
            "desc": "Returns a new Dictionary with only the keys specified in the keys. If a key does not exist in\nthe original Dictionary, it will be ignored.",
            "params": [
                {
                    "name": "dictionary",
                    "desc": "",
                    "lua_type": "Dictionary"
                },
                {
                    "name": "keys",
                    "desc": "The list of keys to pick.",
                    "lua_type": "List | {string}"
                }
            ],
            "returns": [
                {
                    "desc": "The new Dictionary with only the picked keys.",
                    "lua_type": "Dictionary"
                }
            ],
            "function_type": "static",
            "tags": [
                "manipulate"
            ],
            "source": {
                "line": 1384,
                "path": "src/init.lua"
            }
        },
        {
            "name": "Omit",
            "desc": "Returns a new Dictionary with all the keys specified in the keys removed. If a key does not\nexist in the original Dictionary, it will be ignored.",
            "params": [
                {
                    "name": "dictionary",
                    "desc": "",
                    "lua_type": "Dictionary"
                },
                {
                    "name": "keys",
                    "desc": "The list of keys to omit.",
                    "lua_type": "List | {string}"
                }
            ],
            "returns": [
                {
                    "desc": "The new Dictionary with the omitted keys.",
                    "lua_type": "Dictionary"
                }
            ],
            "function_type": "static",
            "tags": [
                "manipulate"
            ],
            "source": {
                "line": 1410,
                "path": "src/init.lua"
            }
        },
        {
            "name": "FilterKeys",
            "desc": "Returns a new Dictionary with only the keys that pass the predicate.",
            "params": [
                {
                    "name": "dictionary",
                    "desc": "",
                    "lua_type": "Dictionary"
                },
                {
                    "name": "predicate",
                    "desc": "A function that takes a key returns a boolean.",
                    "lua_type": "(string) -> boolean"
                }
            ],
            "returns": [
                {
                    "desc": "The new Dictionary with only the keys that pass the predicate.",
                    "lua_type": "Dictionary"
                }
            ],
            "function_type": "static",
            "tags": [
                "manipulate"
            ],
            "source": {
                "line": 1433,
                "path": "src/init.lua"
            }
        },
        {
            "name": "FilterValues",
            "desc": "Returns a new Dictionary with only the values that pass the predicate.",
            "params": [
                {
                    "name": "dictionary",
                    "desc": "",
                    "lua_type": "Dictionary"
                },
                {
                    "name": "predicate",
                    "desc": "A function that takes a value and its key, and returns a boolean.",
                    "lua_type": "(any, string) -> boolean"
                }
            ],
            "returns": [
                {
                    "desc": "The new Dictionary with only the values that pass the predicate.",
                    "lua_type": "Dictionary"
                }
            ],
            "function_type": "static",
            "tags": [
                "manipulate"
            ],
            "source": {
                "line": 1458,
                "path": "src/init.lua"
            }
        },
        {
            "name": "Invert",
            "desc": "Returns a new Dictionary with keys and values swapped. If there are duplicate values, the last\nvalue (when keys are ordered ascending) will be used.\n\nOnly Dictionaries with string values can be inverted. If a value is not a string, it will either\nbe ignored or an error will be thrown, depending on the strict parameter.",
            "params": [
                {
                    "name": "dictionary",
                    "desc": "",
                    "lua_type": "Dictionary"
                },
                {
                    "name": "strict",
                    "desc": "If true, an error will be thrown if a value is not a string. If false, non-string values will be ignored. Defaults to false.",
                    "lua_type": "boolean | nil"
                }
            ],
            "returns": [
                {
                    "desc": "The new Dictionary with keys and values swapped.",
                    "lua_type": "Dictionary"
                }
            ],
            "function_type": "static",
            "tags": [
                "manipulate"
            ],
            "source": {
                "line": 1487,
                "path": "src/init.lua"
            }
        },
        {
            "name": "Unset",
            "desc": "Returns a new Dictionary with the specified key removed. If the key does not exist in the\noriginal Dictionary, the original Dictionary will be returned.",
            "params": [
                {
                    "name": "dictionary",
                    "desc": "",
                    "lua_type": "Dictionary"
                },
                {
                    "name": "key",
                    "desc": "The key to remove.",
                    "lua_type": "string"
                }
            ],
            "returns": [
                {
                    "desc": "The new Dictionary with the key removed.",
                    "lua_type": "Dictionary"
                }
            ],
            "function_type": "static",
            "tags": [
                "manipulate"
            ],
            "source": {
                "line": 1520,
                "path": "src/init.lua"
            }
        }
    ],
    "properties": [],
    "types": [],
    "name": "Dictionary",
    "desc": "A module containing data methods for evaluating and manipulating a [Dictionary] — an immutable\ntable of key-value pairs.\n\nAlso inherits all shared methods from [Immutable](/api/Immutable).",
    "source": {
        "line": 1869,
        "path": "src/init.lua"
    }
}