Skip to main content

EnumUtils

Helds encode Roblox enums into a string

Functions

encodeAsString

EnumUtils.encodeAsString(enumItemEnumItem) → EnumItem

Encodes the value as a string. Note the general format will be such that the string is indexed using a regular Lua value. For example:

print(EnumUtils.encodeAsString(Enum.KeyCode.E)) --> Enum.KeyCode.E

isOfType

EnumUtils.isOfType(
expectedEnumTypeEnumType,
enumItemany
) → (
boolean,--

True if is of type

string--

Error message if there is an error.

)

Returns whether an enum is of the expected type. Useful for asserts.

assert(EnumUtils.isOfType(Enum.KeyCode, enumItem))

toEnum

EnumUtils.toEnum(
enumTypeEnumType,
valueany
) → EnumItem

Attempts to cast an item into an enum

isEncodedEnum

EnumUtils.isEncodedEnum(
valueany?--

String to decode

) → boolean

Returns true if the value is an encoded enum

decodeFromString

EnumUtils.decodeFromString(
valuestring?--

String to decode

) → EnumItem

Decodes the enum from the string name encoding

Show raw api
{
    "functions": [
        {
            "name": "encodeAsString",
            "desc": "Encodes the value as a string. Note the general format will be such that the string is indexed\nusing a regular Lua value. For example:\n\n```lua\nprint(EnumUtils.encodeAsString(Enum.KeyCode.E)) --> Enum.KeyCode.E\n```",
            "params": [
                {
                    "name": "enumItem",
                    "desc": "",
                    "lua_type": "EnumItem"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "EnumItem"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 20,
                "path": "src/enumutils/src/Shared/EnumUtils.lua"
            }
        },
        {
            "name": "isOfType",
            "desc": "Returns whether an enum is of the expected type. Useful for asserts.\n\n```lua\nassert(EnumUtils.isOfType(Enum.KeyCode, enumItem))\n```",
            "params": [
                {
                    "name": "expectedEnumType",
                    "desc": "",
                    "lua_type": "EnumType"
                },
                {
                    "name": "enumItem",
                    "desc": "",
                    "lua_type": "any"
                }
            ],
            "returns": [
                {
                    "desc": "True if is of type",
                    "lua_type": "boolean"
                },
                {
                    "desc": "Error message if there is an error.",
                    "lua_type": "string"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 38,
                "path": "src/enumutils/src/Shared/EnumUtils.lua"
            }
        },
        {
            "name": "toEnum",
            "desc": "Attempts to cast an item into an enum",
            "params": [
                {
                    "name": "enumType",
                    "desc": "",
                    "lua_type": "EnumType"
                },
                {
                    "name": "value",
                    "desc": "",
                    "lua_type": "any"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "EnumItem"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 59,
                "path": "src/enumutils/src/Shared/EnumUtils.lua"
            }
        },
        {
            "name": "isEncodedEnum",
            "desc": "Returns true if the value is an encoded enum",
            "params": [
                {
                    "name": "value",
                    "desc": "String to decode",
                    "lua_type": "any?"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "boolean"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 102,
                "path": "src/enumutils/src/Shared/EnumUtils.lua"
            }
        },
        {
            "name": "decodeFromString",
            "desc": "Decodes the enum from the string name encoding",
            "params": [
                {
                    "name": "value",
                    "desc": "String to decode",
                    "lua_type": "string?"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "EnumItem"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 112,
                "path": "src/enumutils/src/Shared/EnumUtils.lua"
            }
        }
    ],
    "properties": [],
    "types": [],
    "name": "EnumUtils",
    "desc": "Helds encode Roblox enums into a string",
    "source": {
        "line": 6,
        "path": "src/enumutils/src/Shared/EnumUtils.lua"
    }
}