{"id":20659346,"url":"https://github.com/ncpa0cpl/unique-enum-ts","last_synced_at":"2026-04-14T00:32:03.895Z","repository":{"id":57386290,"uuid":"409169332","full_name":"ncpa0cpl/unique-enum-ts","owner":"ncpa0cpl","description":null,"archived":false,"fork":false,"pushed_at":"2022-03-02T10:51:39.000Z","size":6,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-04T21:30:30.928Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","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/ncpa0cpl.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}},"created_at":"2021-09-22T11:02:32.000Z","updated_at":"2022-03-02T10:37:54.000Z","dependencies_parsed_at":"2022-09-02T01:11:32.458Z","dependency_job_id":null,"html_url":"https://github.com/ncpa0cpl/unique-enum-ts","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/ncpa0cpl/unique-enum-ts","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ncpa0cpl%2Funique-enum-ts","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ncpa0cpl%2Funique-enum-ts/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ncpa0cpl%2Funique-enum-ts/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ncpa0cpl%2Funique-enum-ts/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ncpa0cpl","download_url":"https://codeload.github.com/ncpa0cpl/unique-enum-ts/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ncpa0cpl%2Funique-enum-ts/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31776926,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-14T00:11:49.126Z","status":"ssl_error","status_checked_at":"2026-04-14T00:10:29.837Z","response_time":93,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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-11-16T18:34:01.842Z","updated_at":"2026-04-14T00:32:03.858Z","avatar_url":"https://github.com/ncpa0cpl.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Unique Enum TS\n\n#### Utility for creating Enum-like objects with unique values\n\n## Usage\n\nDefine the enum:\n\n```ts\nimport { UniqueEnum } from \"unique-enum-ts\";\n\nconst MyEnum = UniqueEnum({\n  FOO: \"FOO\",\n  BAR: \"BAR\",\n} as const);\n\n// OR\n// Use the TS enum syntax and assert the values uniqueness with the UniqueEnum function\n\nenum MyEnum {\n  FOO = \"FOO\",\n  BAR = \"BAR\",\n}\n\nUniqueEnum(MyEnum);\n```\n\nIf you don't use the TS enums syntax, you will need to extract the enum type like this:\n\n```ts\ntype MyEnumValues = typeof MyEnum[keyof typeof MyEnum];\n\nfunction baz(myEnum: MyEnumValues) {\n  switch (myEnum) {\n    case MyEnum.FOO:\n      // do something when myEnum === 'foo'\n      break;\n    case MyEnum.BAR:\n      // do something when myEnum === 'bar'\n      break;\n  }\n}\n```\n\n## Enum Uniqueness\n\nUnique Enum does not do a uniqueness check at runtime. It only provides Typescript type checking on the enum values.\n\nThis means that the following declaration will throw an compile error (since the value \"foo\" is used twice):\n\n```ts\nimport { UniqueEnum } from \"unique-enum-ts\";\n\nconst MyEnum = UniqueEnum({\n  FOO: \"foo\",\n  BAR: \"bar\",\n  ANOTHER_FOO: \"foo\",\n} as const);\n```\n\nHowever if the compilation error were to be ignored, this code will execute just fine, without any errors or warnings.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fncpa0cpl%2Funique-enum-ts","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fncpa0cpl%2Funique-enum-ts","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fncpa0cpl%2Funique-enum-ts/lists"}