{"id":13493134,"url":"https://github.com/dislick/enum-js","last_synced_at":"2025-02-27T02:18:28.145Z","repository":{"id":77037269,"uuid":"12330605","full_name":"dislick/enum-js","owner":"dislick","description":"Write protected, enumerable datatypes in pure JavaScript","archived":false,"fork":false,"pushed_at":"2016-01-20T07:41:56.000Z","size":40,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-23T21:35:34.971Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dislick.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-08-23T19:10:46.000Z","updated_at":"2016-01-20T07:41:57.000Z","dependencies_parsed_at":"2023-03-21T02:14:48.983Z","dependency_job_id":null,"html_url":"https://github.com/dislick/enum-js","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dislick%2Fenum-js","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dislick%2Fenum-js/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dislick%2Fenum-js/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dislick%2Fenum-js/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dislick","download_url":"https://codeload.github.com/dislick/enum-js/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240964357,"owners_count":19885733,"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-07-31T19:01:12.592Z","updated_at":"2025-02-27T02:18:28.118Z","avatar_url":"https://github.com/dislick.png","language":"JavaScript","readme":"enum.js\n=======\n\nWarning\n-------\n\nThis repository is no longer needed since the introduction of [ES6 Symbols](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Symbol).\n\nWhat's this?\n----\n\nenum.js provides enumerable datatypes in pure JavaScript. It ensures type safety and gives you useful methods for your enums.\n\nAPI\n---\n\n### Constructor\n\nYou can create enums using an array of enum names (Strings).\n\n```\nnew Enum(enumNames, [options])\n```\n\n```\nvar Days = new Enum([ 'Monday', 'Tuesday', 'Wednesday' ], { finalize: false });\n```\n\n```\nvar Days = new Enum([ 'Monday', 'Tuesday', 'Wednesday' ], { startIndex: 1 });\n```\n\nSometimes you want the enum to have a friendly textual representation which is different from it's name.\nFor those cases, the enum array can be an array of objects, which have 2 properties - name \u0026 text.\n\n```\nnew Enum(enumObjects, [options])\n```\n\n```\nvar Foo = new Enum([ { name: 'Bar', text: 'Bar text' }, { name: 'Baz', text: 'Baz text' } ]);\n```\n\n### enum.toString\n\n```\nDays.Monday.toString();\n```\n\nReturns a string representation of the enum name.\n\n### enum.toText\n\n```\nDays.Monday.toText();\n```\n\nReturns the textual representation of the enum. If the enum was created with an Array of names (Strings), the text will\nequal the name. If the enum was created with an Array of objects, it will equal the text value passed.\n\n### enum.toOrdinal\n\n```\nDays.Monday.toOrdinal();\n```\n\nReturns the ordinal value of the enum.\n\n### getByName\n\n```\nDays.getByName('Monday');\n```\n\nGet the reference enum by a string.\n\n### getByOrdinal\n\n```\nDays.getByOrdinal(0);\n```\n\nGet the reference enum by a its ordinal value.\n\n### getNames\n\n```\nDays.getNames();\n```\n\nReturns all available enums as strings. You won't get any references with this method, just pure strings.\n\n### contains\n\n```\nDays.contains('Monday');\n```\n\nReturns true if the Enum contains the the enum name passed.\n\nCustomization\n-------------\n\n### finalize\n\nDatatype: `Boolean`\nDefault: `true`\n\n```\nvar enumerableObject = new Enum([], { finalize: false });\n```\n\nFinalizes your enum object so it is write protected. Ensures type safety.\n\n### startIndex\n\nDatatype: `Number`\nDefault: `0`\n\n```\nvar enumerableObject = new Enum([], { startIndex: 1 });\n```\n\nWill start the ordinal values from startIndex.\n","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdislick%2Fenum-js","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdislick%2Fenum-js","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdislick%2Fenum-js/lists"}