Skip to main content

Util

Cmdr utilities module.

Functions​

MakeDictionary​

Util.MakeDictionary(array: {any}) → {[any]: true}

Takes an array and flips its values into dictionary keys with value of true.

DictionaryKeys​

Util.DictionaryKeys(dict: {[any]: any}) → {any}

Takes a dictionary and returns its keys.

MakeFuzzyFinder​

Util.MakeFuzzyFinder(setOrContainer: any) → (
string,
boolean?,
boolean?
) → any

Returns a function that is a fuzzy finder for the specified set or container.

Can pass an array of strings, array of instances, array of EnumItems, array of dictionaries with a Name key or an instance (in which case its children will be used).

Exact matches will be inserted in the front of the resulting array.

GetNames​

Util.GetNames(instances: any) → {string}

Takes an array of instances (or anything with a Name property) and maps them into an array of their names. If no Name property is present, then tostring will be called instead.

SplitStringSimple​

Util.SplitStringSimple(
input: string,
separator: string?
) → {string}

Splits a string using a simple separator (no quote parsing)

ParseEscapeSequences​

Util.ParseEscapeSequences(text: string) → string

Parses escape sequences into their fully qualified characters

EncodeEscapedOperator​

Util.EncodeEscapedOperator(
text: string,
operator: string
) → string

Encodes escaped operators in a string, replacing them with their unicode representations.

EncodeEscapedOperators​

Util.EncodeEscapedOperators(text: string) → string

Encodes all escaped operators in a string, replacing them with their unicode representations.

SplitString​

Util.SplitString(
text: string,
max: number?
) → {string}

Splits a string by space but taking into account quoted sequences which will be treated as a single argument.

MashExcessArguments​

Util.MashExcessArguments(
arguments: {string},
max: number
) → {string}

Takes an array of arguments and a max value. Any indicies past the max value will be appended to the last valid argument.

TrimString​

Util.TrimString(str: string) → string

Trims whitespace from both sides of a string.

GetTextSize​

Util.GetTextSize(
text: string,
label: TextLabel,
size: Vector2?
) → Vector2

Returns the text bounds size based on given text, label (from which properties will be pulled), and optional Vector2 container size.

MakeEnumType​

Util.MakeEnumType(
name: string,
values: any
) → TypeDefinition

Makes an Enum type.

ParsePrefixedUnionType​

Util.ParsePrefixedUnionType(
typeValue: string,
rawValue: string
) → (
string?,
string?,
string?
)

Parses a prefixed union type argument (such as %Team)

MakeListableType​

Util.MakeListableType(
typeDefinition: TypeDefinition,
override: table
) → TypeDefinition

Creates a listable type from a singular type

RunCommandString​

Util.RunCommandString(
dispatcher: Dispatcher,
commandString: string
) → string?

Runs a command string, chaining commands with && and replacing || with the previous command's output.

RunEmbeddedCommands​

Util.RunEmbeddedCommands(
dispatcher: Dispatcher,
str: string
) → string

Runs embedded commands and replaces them

SubstituteArgs​

Util.SubstituteArgs(
str: string,
replace: any
) → string

Replaces arguments in the format $1, $2, $something with whatever the given function returns for it.

MakeAliasCommand​

Util.MakeAliasCommand(
name: string,
commandString: string
) → CommandDefinition

Creates an alias command, should only be used on the client.

MakeSequenceType​

Util.MakeSequenceType(options: {
Transform: function?,
Parse: function?,
Constructor: function?,
TransformEach: function?,
ValidateEach: function?,
Prefixes: {string}?,
Length: number?
}) → ArgumentDefinition

Makes a type that contains a sequence, e.g. Vector3 or Color3 For options, one of Constructor or Parse is required

SplitPrioritizedDelimeter​

Util.SplitPrioritizedDelimeter(
text: string,
delimiters: {string}
) → {string}?

Splits a string by a single delimeter chosen from the given set. The first matching delimeter from the set becomes the split character.

Map​

Util.Map(
array: {any},
callback: (
any,
number
) → any
) → {any}

Maps values of an array through a callback and returns an array of mapped values.

Each​

Util.Each(
callback: (any) → any,
...: any
) → ...any

Maps arguments #2-n through callback and returns values as tuple.

EmulateTabstops​

Util.EmulateTabstops(
text: string,
tabWidth: number
) → string

Emulates tabstops with spaces.

Mutex​

Util.Mutex() → function--

A function that locks the mutex and returns a function to unlock it.

Creates a mutex for synchronizing coroutines.

SuppressDeprecationWarning​

Util:SuppressDeprecationWarning(names: string | {string}) → ()

Suppresses a deprecation warning for a method.

Show raw api
{
    "functions": [
        {
            "name": "MakeDictionary",
            "desc": "Takes an array and flips its values into dictionary keys with value of true.",
            "params": [
                {
                    "name": "array",
                    "desc": "",
                    "lua_type": "{ any }"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "{ [any]: true }\n"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 126,
                "path": "Cmdr/CmdrClient/Shared/Util.luau"
            }
        },
        {
            "name": "DictionaryKeys",
            "desc": "Takes a dictionary and returns its keys.",
            "params": [
                {
                    "name": "dict",
                    "desc": "",
                    "lua_type": "{ [any]: any }"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "{ any }\n"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 140,
                "path": "Cmdr/CmdrClient/Shared/Util.luau"
            }
        },
        {
            "name": "MakeFuzzyFinder",
            "desc": "Returns a function that is a fuzzy finder for the specified set or container.\n\nCan pass an array of strings, array of instances, array of EnumItems,\narray of dictionaries with a Name key or an instance (in which case its children will be used).\n\nExact matches will be inserted in the front of the resulting array.",
            "params": [
                {
                    "name": "setOrContainer",
                    "desc": "",
                    "lua_type": "any"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "(string, boolean?, boolean?) -> any\n"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 160,
                "path": "Cmdr/CmdrClient/Shared/Util.luau"
            }
        },
        {
            "name": "GetNames",
            "desc": "Takes an array of instances (or anything with a Name property) and maps them into an array of their names.\nIf no Name property is present, then tostring will be called instead.",
            "params": [
                {
                    "name": "instances",
                    "desc": "",
                    "lua_type": "any"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "{ string }\n"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 260,
                "path": "Cmdr/CmdrClient/Shared/Util.luau"
            }
        },
        {
            "name": "SplitStringSimple",
            "desc": "Splits a string using a simple separator (no quote parsing)",
            "params": [
                {
                    "name": "input",
                    "desc": "",
                    "lua_type": "string"
                },
                {
                    "name": "separator",
                    "desc": "",
                    "lua_type": "string?"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "{ string }\n"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 269,
                "path": "Cmdr/CmdrClient/Shared/Util.luau"
            }
        },
        {
            "name": "ParseEscapeSequences",
            "desc": "Parses escape sequences into their fully qualified characters",
            "params": [
                {
                    "name": "text",
                    "desc": "",
                    "lua_type": "string"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "string\n"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 286,
                "path": "Cmdr/CmdrClient/Shared/Util.luau"
            }
        },
        {
            "name": "EncodeEscapedOperator",
            "desc": "Encodes escaped operators in a string, replacing them with their unicode representations.",
            "params": [
                {
                    "name": "text",
                    "desc": "",
                    "lua_type": "string"
                },
                {
                    "name": "operator",
                    "desc": "",
                    "lua_type": "string"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "string\n"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 299,
                "path": "Cmdr/CmdrClient/Shared/Util.luau"
            }
        },
        {
            "name": "EncodeEscapedOperators",
            "desc": "Encodes all escaped operators in a string, replacing them with their unicode representations.",
            "params": [
                {
                    "name": "text",
                    "desc": "",
                    "lua_type": "string"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "string\n"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 315,
                "path": "Cmdr/CmdrClient/Shared/Util.luau"
            }
        },
        {
            "name": "SplitString",
            "desc": "Splits a string by space but taking into account quoted sequences which will be treated as a single argument.",
            "params": [
                {
                    "name": "text",
                    "desc": "",
                    "lua_type": "string"
                },
                {
                    "name": "max",
                    "desc": "",
                    "lua_type": "number?"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "{ string }\n"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 339,
                "path": "Cmdr/CmdrClient/Shared/Util.luau"
            }
        },
        {
            "name": "MashExcessArguments",
            "desc": "Takes an array of arguments and a max value. Any indicies past the max value will be appended to the last valid argument.",
            "params": [
                {
                    "name": "arguments",
                    "desc": "",
                    "lua_type": "{ string }"
                },
                {
                    "name": "max",
                    "desc": "",
                    "lua_type": "number"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "{ string }\n"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 390,
                "path": "Cmdr/CmdrClient/Shared/Util.luau"
            }
        },
        {
            "name": "TrimString",
            "desc": "Trims whitespace from both sides of a string.",
            "params": [
                {
                    "name": "str",
                    "desc": "",
                    "lua_type": "string"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "string\n"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 408,
                "path": "Cmdr/CmdrClient/Shared/Util.luau"
            }
        },
        {
            "name": "GetTextSize",
            "desc": "Returns the text bounds size based on given text, label (from which properties will be pulled), and optional Vector2 container size.",
            "params": [
                {
                    "name": "text",
                    "desc": "",
                    "lua_type": "string"
                },
                {
                    "name": "label",
                    "desc": "",
                    "lua_type": "TextLabel"
                },
                {
                    "name": "size",
                    "desc": "",
                    "lua_type": "Vector2?"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Vector2\n"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 417,
                "path": "Cmdr/CmdrClient/Shared/Util.luau"
            }
        },
        {
            "name": "MakeEnumType",
            "desc": "Makes an Enum type.",
            "params": [
                {
                    "name": "name",
                    "desc": "",
                    "lua_type": "string"
                },
                {
                    "name": "values",
                    "desc": "",
                    "lua_type": "any"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "TypeDefinition"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 447,
                "path": "Cmdr/CmdrClient/Shared/Util.luau"
            }
        },
        {
            "name": "ParsePrefixedUnionType",
            "desc": "Parses a prefixed union type argument (such as %Team)",
            "params": [
                {
                    "name": "typeValue",
                    "desc": "",
                    "lua_type": "string"
                },
                {
                    "name": "rawValue",
                    "desc": "",
                    "lua_type": "string"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "string?"
                },
                {
                    "desc": "",
                    "lua_type": "string?"
                },
                {
                    "desc": "",
                    "lua_type": "string?"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 469,
                "path": "Cmdr/CmdrClient/Shared/Util.luau"
            }
        },
        {
            "name": "MakeListableType",
            "desc": "Creates a listable type from a singular type",
            "params": [
                {
                    "name": "typeDefinition",
                    "desc": "",
                    "lua_type": "TypeDefinition"
                },
                {
                    "name": "override",
                    "desc": "",
                    "lua_type": "table"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "TypeDefinition"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 504,
                "path": "Cmdr/CmdrClient/Shared/Util.luau"
            }
        },
        {
            "name": "RunCommandString",
            "desc": "Runs a command string, chaining commands with && and replacing || with the previous command's output.",
            "params": [
                {
                    "name": "dispatcher",
                    "desc": "",
                    "lua_type": "Dispatcher"
                },
                {
                    "name": "commandString",
                    "desc": "",
                    "lua_type": "string"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "string?\n"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 533,
                "path": "Cmdr/CmdrClient/Shared/Util.luau"
            }
        },
        {
            "name": "RunEmbeddedCommands",
            "desc": "Runs embedded commands and replaces them",
            "params": [
                {
                    "name": "dispatcher",
                    "desc": "",
                    "lua_type": "Dispatcher"
                },
                {
                    "name": "str",
                    "desc": "",
                    "lua_type": "string"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "string\n"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 559,
                "path": "Cmdr/CmdrClient/Shared/Util.luau"
            }
        },
        {
            "name": "SubstituteArgs",
            "desc": "Replaces arguments in the format $1, $2, $something with whatever the given function returns for it.",
            "params": [
                {
                    "name": "str",
                    "desc": "",
                    "lua_type": "string"
                },
                {
                    "name": "replace",
                    "desc": "",
                    "lua_type": "any"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "string\n"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 590,
                "path": "Cmdr/CmdrClient/Shared/Util.luau"
            }
        },
        {
            "name": "MakeAliasCommand",
            "desc": "Creates an alias command, should only be used on the client.",
            "params": [
                {
                    "name": "name",
                    "desc": "",
                    "lua_type": "string"
                },
                {
                    "name": "commandString",
                    "desc": "",
                    "lua_type": "string"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "CommandDefinition"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 614,
                "path": "Cmdr/CmdrClient/Shared/Util.luau"
            }
        },
        {
            "name": "MakeSequenceType",
            "desc": "Makes a type that contains a sequence, e.g. Vector3 or Color3\nFor options, one of Constructor or Parse is required",
            "params": [
                {
                    "name": "options",
                    "desc": "",
                    "lua_type": "{ Transform: function?, Parse: function?, Constructor: function?, TransformEach: function?, ValidateEach: function?, Prefixes: {string}?, Length: number? }"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "ArgumentDefinition"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 664,
                "path": "Cmdr/CmdrClient/Shared/Util.luau"
            }
        },
        {
            "name": "SplitPrioritizedDelimeter",
            "desc": "Splits a string by a single delimeter chosen from the given set. The first matching delimeter from the set becomes the split character.",
            "params": [
                {
                    "name": "text",
                    "desc": "",
                    "lua_type": "string"
                },
                {
                    "name": "delimiters",
                    "desc": "",
                    "lua_type": "{ string }"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "{ string }?\n"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 720,
                "path": "Cmdr/CmdrClient/Shared/Util.luau"
            }
        },
        {
            "name": "Map",
            "desc": "Maps values of an array through a callback and returns an array of mapped values.",
            "params": [
                {
                    "name": "array",
                    "desc": "",
                    "lua_type": "{ any }"
                },
                {
                    "name": "callback",
                    "desc": "",
                    "lua_type": "(any, number) -> any"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "{ any }\n"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 734,
                "path": "Cmdr/CmdrClient/Shared/Util.luau"
            }
        },
        {
            "name": "Each",
            "desc": "Maps arguments #2-n through callback and returns values as tuple.",
            "params": [
                {
                    "name": "callback",
                    "desc": "",
                    "lua_type": "(any) -> any"
                },
                {
                    "name": "...",
                    "desc": "",
                    "lua_type": "any"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "...any\n"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 747,
                "path": "Cmdr/CmdrClient/Shared/Util.luau"
            }
        },
        {
            "name": "EmulateTabstops",
            "desc": "Emulates tabstops with spaces.",
            "params": [
                {
                    "name": "text",
                    "desc": "",
                    "lua_type": "string"
                },
                {
                    "name": "tabWidth",
                    "desc": "",
                    "lua_type": "number"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "string\n"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 760,
                "path": "Cmdr/CmdrClient/Shared/Util.luau"
            }
        },
        {
            "name": "Mutex",
            "desc": "Creates a mutex for synchronizing coroutines.",
            "params": [],
            "returns": [
                {
                    "desc": "A function that locks the mutex and returns a function to unlock it.",
                    "lua_type": "function"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 790,
                "path": "Cmdr/CmdrClient/Shared/Util.luau"
            }
        },
        {
            "name": "_registerDeprecationWarning",
            "desc": "Registers a deprecation warning for a method.",
            "params": [
                {
                    "name": "name",
                    "desc": "",
                    "lua_type": "string"
                },
                {
                    "name": "description",
                    "desc": "",
                    "lua_type": "string"
                }
            ],
            "returns": [],
            "function_type": "method",
            "private": true,
            "source": {
                "line": 819,
                "path": "Cmdr/CmdrClient/Shared/Util.luau"
            }
        },
        {
            "name": "_emitDeprecationWarning",
            "desc": "Emits a deprecation warning for a method if it has been called. This should be called at the start of a deprecated method.",
            "params": [
                {
                    "name": "name",
                    "desc": "",
                    "lua_type": "string"
                }
            ],
            "returns": [],
            "function_type": "method",
            "private": true,
            "source": {
                "line": 840,
                "path": "Cmdr/CmdrClient/Shared/Util.luau"
            }
        },
        {
            "name": "SuppressDeprecationWarning",
            "desc": "Suppresses a deprecation warning for a method.",
            "params": [
                {
                    "name": "names",
                    "desc": "",
                    "lua_type": "string | { string }"
                }
            ],
            "returns": [],
            "function_type": "method",
            "source": {
                "line": 854,
                "path": "Cmdr/CmdrClient/Shared/Util.luau"
            }
        }
    ],
    "properties": [
        {
            "name": "_deprecationWarnings",
            "desc": "A collection of deprecated methods and their warnings.",
            "lua_type": "{ [string]: { Description: string, Suppressed: boolean, Emitted: boolean } }",
            "private": true,
            "readonly": true,
            "source": {
                "line": 104,
                "path": "Cmdr/CmdrClient/Shared/Util.luau"
            }
        }
    ],
    "types": [],
    "name": "Util",
    "desc": "Cmdr utilities module.",
    "source": {
        "line": 94,
        "path": "Cmdr/CmdrClient/Shared/Util.luau"
    }
}