Skip to main content

Enumerator

Types#

EnumeratorObject#

Enum
interface EnumeratorObject {
cast: (value: any) → (
EnumeratorItem<Value> | boolean,
string?
)--

Attempts to cast a value to an EnumeratorItem.

fromRawValue: (rawValue: Value) → EnumeratorItem<Value>?--

Attempts to create an EnumeratorItem from a raw value.

getEnumeratorItems: () → {EnumeratorItem<Value>}--

Returns a table of all EnumeratorItems in the EnumeratorObject.

getSortedEnumeratorItems: () → {EnumeratorItem<Value>}--

Returns a table of all EnumeratorItems in the EnumeratorObject, sorted by value.

isEnumValue: (value: any) → boolean--

Returns whether or not a value is an EnumeratorItem.

}

An EnumeratorObject is meant to represent a collection of unique values.

Functions#

Enumerator#

Enumerator.Enumerator(
enumName: string,--

The name of the enumeration.

enumValues: {string} | {[string]: any}--

The values of the enumeration.

) → EnumeratorObject--

The new EnumeratorObject.

Creates a new EnumeratorObject.

local Fruit = enumerator("Fruit", {"Apple", "Banana", "Orange", "Grape"})
local Numbers = enumerator("Numbers", {
	One = 1;
	Two = 2;
	Three = 3;
})
Show raw api
{
    "functions": [
        {
            "name": "Enumerator",
            "desc": "Creates a new `EnumeratorObject`.\n\n```lua\nlocal Fruit = enumerator(\"Fruit\", {\"Apple\", \"Banana\", \"Orange\", \"Grape\"})\nlocal Numbers = enumerator(\"Numbers\", {\n\tOne = 1;\n\tTwo = 2;\n\tThree = 3;\n})\n```",
            "params": [
                {
                    "name": "enumName",
                    "desc": "The name of the enumeration.",
                    "lua_type": "string"
                },
                {
                    "name": "enumValues",
                    "desc": "The values of the enumeration.",
                    "lua_type": "{string} | {[string]: any}"
                }
            ],
            "returns": [
                {
                    "desc": "The new EnumeratorObject.",
                    "lua_type": "EnumeratorObject"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 116,
                "path": "src/init.lua"
            }
        }
    ],
    "properties": [],
    "types": [
        {
            "name": "EnumeratorObject",
            "desc": "An EnumeratorObject is meant to represent a collection of unique values.",
            "fields": [
                {
                    "name": "cast",
                    "lua_type": "(value: any) -> (EnumeratorItem<Value> | boolean, string?)",
                    "desc": "Attempts to cast a value to an EnumeratorItem."
                },
                {
                    "name": "fromRawValue",
                    "lua_type": "(rawValue: Value) -> EnumeratorItem<Value>?",
                    "desc": "Attempts to create an EnumeratorItem from a raw value."
                },
                {
                    "name": "getEnumeratorItems",
                    "lua_type": "() -> {EnumeratorItem<Value>}",
                    "desc": "Returns a table of all EnumeratorItems in the EnumeratorObject."
                },
                {
                    "name": "getSortedEnumeratorItems",
                    "lua_type": "() -> {EnumeratorItem<Value>}",
                    "desc": "Returns a table of all EnumeratorItems in the EnumeratorObject, sorted by value."
                },
                {
                    "name": "isEnumValue",
                    "lua_type": "(value: any) -> boolean",
                    "desc": "Returns whether or not a value is an EnumeratorItem."
                }
            ],
            "tags": [
                "Enum"
            ],
            "source": {
                "line": 90,
                "path": "src/init.lua"
            }
        }
    ],
    "name": "Enumerator",
    "desc": "",
    "source": {
        "line": 92,
        "path": "src/init.lua"
    }
}