{"id":24638461,"url":"https://github.com/chuckterry/enumjs","last_synced_at":"2025-08-24T14:42:02.208Z","repository":{"id":74005750,"uuid":"476840014","full_name":"ChuckTerry/EnumJS","owner":"ChuckTerry","description":"Enum Implementation in Javascript","archived":false,"fork":false,"pushed_at":"2022-04-09T12:16:05.000Z","size":23,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-20T09:42:10.590Z","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":"agpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ChuckTerry.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":"2022-04-01T19:09:16.000Z","updated_at":"2022-04-01T19:11:33.000Z","dependencies_parsed_at":null,"dependency_job_id":"c184b19c-eafd-4df1-b992-f8a72013d1a3","html_url":"https://github.com/ChuckTerry/EnumJS","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ChuckTerry/EnumJS","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ChuckTerry%2FEnumJS","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ChuckTerry%2FEnumJS/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ChuckTerry%2FEnumJS/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ChuckTerry%2FEnumJS/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ChuckTerry","download_url":"https://codeload.github.com/ChuckTerry/EnumJS/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ChuckTerry%2FEnumJS/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263476357,"owners_count":23472567,"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":"2025-01-25T10:14:33.101Z","updated_at":"2025-07-04T08:34:28.315Z","avatar_url":"https://github.com/ChuckTerry.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# EnumJS\nEnum Implementation in Javascript with ability to lock and unlock.\n\nVersion: 1.2.1\n\n## Usage\n### Instantiation\n  ```javascript\n  // The Starting Value will always be the first vaue passed to the constructor\n  new Enum(/*Array of States*/, /*Surpress Errors*/ [optional]);\n  const myEnum = new Enum(['OFF', 'LOW', 'MID', 'HIGH'], false);\n  \n  // Or use the static from() method\n  const myEnum = Enum.from('OFF', 'LOW', 'MID', 'HIGH']);\n  ```\n\n## Check if object is Enum\n  ```javascript\n  Enum.isEnum(myEnum) // --\u003e True\n  ```\n\n### Get Current State\n  ```javascript\n  const currentState = myEnum.getState(); // --\u003e 'OFF'\n\n  // Or use the accessor\n  const currentState = myEnum.state; // --\u003e 'OFF'\n  ```\n\n### Set Current State\n  ```javascript\n  myEnum.setState('MID'); // --\u003e 'MID'\n\n  // Or use the accessor\n  myEnum.state = 'MID'; // --\u003e 'MID'\n  ```\n\n### Get Number of Valid States\n  ```javascript\n  myEnum.length; // --\u003e 4\n  ```\n\n### Get All Valid States\n  ```javascript\n  myEnum.getValidStates(); // --\u003e ['OFF', 'LOW', 'MID', 'HIGH']\n  ```\n\n### Test if State is Valid\n  ```javascript\n  myEnum.isValidState('MAX'); // --\u003e false\n  ```\n\n### Locking\n  ```javascript\n  // Locking an Enum will return a key (Symbol) used to unlock it again\n  const myKey = myEnum.lock();\n\n  myEnum.setState('LOW'); // Throws an error (Or nothing if surpressed);\n\n  myEnum.unlock(myKey);\n  myEnum.setState('LOW'); // Succeeds\n\n  // Locking Enum with a \"true\" parameter locks it permanently and returns true\n  myEnum.lock(true); // --\u003e true\n  ```\n\n### Checking Lock Status\n  ```javascript\n  myEnum.isLocked(); // --\u003e true\n  ```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchuckterry%2Fenumjs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchuckterry%2Fenumjs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchuckterry%2Fenumjs/lists"}