{"id":15888237,"url":"https://github.com/corecii/lua-enum-simple","last_synced_at":"2025-04-02T16:44:21.259Z","repository":{"id":105909008,"uuid":"426878306","full_name":"Corecii/lua-enum-simple","owner":"Corecii","description":"A super-simple Enum-like object for Roblox Lua","archived":false,"fork":false,"pushed_at":"2021-11-13T22:35:48.000Z","size":768,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-02-08T07:25:18.051Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Lua","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Corecii.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-11-11T05:10:41.000Z","updated_at":"2021-11-13T22:35:50.000Z","dependencies_parsed_at":null,"dependency_job_id":"ee8c95e8-898b-418d-9949-71467ab04b3a","html_url":"https://github.com/Corecii/lua-enum-simple","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Corecii%2Flua-enum-simple","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Corecii%2Flua-enum-simple/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Corecii%2Flua-enum-simple/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Corecii%2Flua-enum-simple/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Corecii","download_url":"https://codeload.github.com/Corecii/lua-enum-simple/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246853373,"owners_count":20844568,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-06T06:06:49.655Z","updated_at":"2025-04-02T16:44:21.236Z","avatar_url":"https://github.com/Corecii.png","language":"Lua","funding_links":[],"categories":[],"sub_categories":[],"readme":"# LuaEnum\n\nA super-simple enum type and a super-simple enum collection type.\n\n[Documentation](https://corecii.github.io/lua-enum-simple/)\n\nInstall with [wally](https://wally.run):\n```toml\n# wally.toml\n[dependencies]\nLuaEnum = \"corecii/lua-enum-simple@0.1.0\"\n```\n\n[or use a packaged release model](https://github.com/Corecii/lua-enum-simple/releases/latest)\n\n---\n\nThink Roblox's enums, not Rust's enums.\n\nI couldn't find a good mix between serializability, debugability, and simplicity, so this module lets you choose between:\n* \"Id\" representation, `\"Animal.Dog\"`\n* \"ValueId\" representation, `\"Animal.1\"`\n* \"Name\" representation, `\"Dog\"`\n* \"Value\" representation, `1`\n* \"Symbol\" representation, a userdata with `tostring(symbol) == \"\u003cSymbol Animal.Dog\u003e\"`\n\nIt defaults to `Id` representation.\n\nAdditionally, this module provides a way to turn a tree of modulescripts and folders into a tree of EnumCollections and Enums.\n\n---\n\nLuaEnum Example:\n```lua\nlocal Animals = LuaEnum.new(\"Animals\", {\n  Dog = 1,\n  Cat = 2,\n  Mouse = 3,\n})\n\nprint(Animals.Dog) --\u003e \"Animals.Dog\"\n\nprint(LuaEnum.is(Animals)) --\u003e true\n\nprint(LuaEnum.isItem(Animals, Animals.Dog)) --\u003e true\nprint(LuaEnum.isItem(Animals, \"x\")) --\u003e false\n\nlocal function speak(animal)\n  assert(LuaEnum.isItem(Animals, animal))\n\n  if animal == Animals.Dog then\n    print(\"woof\")\n  elseif animal == Animals.Cat then\n    print(\"meow\")\n  elseif animal == Animals.Mouse then\n    print(\"sque\")\n  end\nend\n\nspeak(Animals.Cat) --\u003e \"meow\"\n\n-- Errors:\n\nlocal x = Animals.Lizard --\u003e Error: Item \"Lizard\" does not exist in LuaEnum Animals\n\nAnimals.Cat = 5 --\u003e Error: Attempt to modify a readonly table\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcorecii%2Flua-enum-simple","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcorecii%2Flua-enum-simple","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcorecii%2Flua-enum-simple/lists"}