{"id":24901549,"url":"https://github.com/pgalias/js-enumify","last_synced_at":"2025-06-29T03:42:15.690Z","repository":{"id":57283057,"uuid":"158298801","full_name":"pgalias/js-enumify","owner":"pgalias","description":"Enum lib","archived":false,"fork":false,"pushed_at":"2019-04-25T21:27:02.000Z","size":28,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-18T01:37:20.294Z","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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pgalias.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2018-11-19T22:33:46.000Z","updated_at":"2019-04-25T21:25:59.000Z","dependencies_parsed_at":"2022-09-17T13:01:21.958Z","dependency_job_id":null,"html_url":"https://github.com/pgalias/js-enumify","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pgalias%2Fjs-enumify","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pgalias%2Fjs-enumify/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pgalias%2Fjs-enumify/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pgalias%2Fjs-enumify/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pgalias","download_url":"https://codeload.github.com/pgalias/js-enumify/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245898316,"owners_count":20690466,"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-02-01T21:16:34.914Z","updated_at":"2025-03-27T18:19:23.703Z","avatar_url":"https://github.com/pgalias.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# js-enumify [![Build Status](https://travis-ci.com/pgalias/js-enumify.svg?branch=master)](https://travis-ci.com/pgalias/js-enumify) [![Coverage Status](https://coveralls.io/repos/github/pgalias/js-enumify/badge.svg)](https://coveralls.io/github/pgalias/js-enumify)\n\njs-enumify introduces Enum Type to JavaScript. Works well on node and browser environments.\n\n## Installing\n\n- `npm install js-enumify`\n\n## Usage\n\n- Creating enum\n````js\nimport Enum from 'js-enumify'; // or const Enum = require('js-enumify');\n\nclass SomeEnum extends Enum {\n    static get FOO() {return 'foo';}\n    static get BAR() {return 320;}\n    static get BAZ() {return false;}\n    static get ARR() {return ['a', 2, undefined];}\n    static get FUN() {return (a) =\u003e a + 1;}\n    static get OBJ() {return {a:1, b:3};}\n}\n````\n\n- Getting enum value\n````js\nSomeEnum.FOO; // 'foo'\nSomeEnum.take(SomeEnum.FOO); // Foo { key: 'FOO', value: 'foo' } \n````\n\n- Getting all enums\n````js\nSomeEnum.all() // [Foo { key: 'FOO', value: 'foo' }, Foo { key: 'BAR', value: 320 }, Foo { key: 'BAZ', value: false }]\n````\n\n- Getting all enum keys\n````js\nSomeEnum.keys() // ['FOO', 'BAR', 'BAZ']\n````\n\n- Getting all enum values\n````js\nSomeEnum.values() // ['foo', 320, false]\n````\n\n- Checking if current enum is equal to given one\n````js\nconst foo = SomeEnum.take(SomeEnum.BAR);\nfoo.is(SomeEnum.BAR) // true\nfoo.is(320) // true\nfoo.is(SomeEnum.BAR) // false\n````\n\n- Checking if current enum value is equal to one of given ones\n````js\nconst foo = SomeEnum.take(SomeEnum.BAR);\nfoo.oneOf([SomeEnum.BAR, undefined, 'foo']); // true\nfoo.oneOf([SomeEnum.BAZ, false, 'foo']); // false\n````\n\n- Parsing enum value to string\n````js\nconst foo = SomeEnum.take(SomeEnum.BAR);\nfoo.toString(); // '320'\nString(foo); // '320'\nfoo + ''; // '320'\n````\n\n## Testing\n\n- `npm test`\n\n## Changelog\n\nSee [Changelog](https://github.com/pgalias/js-enumify/blob/master/CHANGELOG.md)\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE.md](https://github.com/pgalias/js-enumify/blob/master/LICENSE) file for details\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpgalias%2Fjs-enumify","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpgalias%2Fjs-enumify","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpgalias%2Fjs-enumify/lists"}