https://github.com/qeepsake/ts-string-as-enum
Convert a string to an enum type with TypeScript ⚡️
https://github.com/qeepsake/ts-string-as-enum
Last synced: 12 months ago
JSON representation
Convert a string to an enum type with TypeScript ⚡️
- Host: GitHub
- URL: https://github.com/qeepsake/ts-string-as-enum
- Owner: Qeepsake
- Created: 2022-10-04T13:07:49.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2022-10-04T13:40:08.000Z (almost 4 years ago)
- Last Synced: 2025-07-11T07:44:27.731Z (about 1 year ago)
- Language: TypeScript
- Size: 334 KB
- Stars: 2
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Convert String to Enum with TypeScript
Tiny (zero dependencies) utility to Convert string to enum type with TypeScript ⚡️
## Install
```bash
npm install --save @qeepsake/ts-string-as-enum
```
## Usage
```ts
export declare enum Colors {
/** JSDoc */
Blue = "Blue",
/** JSDoc */
Red = "Red",
/** JSDoc */
Green = "Green",
}
tsStringAsEnum(Colors, 'blue'); // -> Colors.Blue
```
## License
MIT © [lukebrandonfarrell](https://github.com/lukebrandonfarrell)
## Contributors ✨
Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):
This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!