Skip to content
This repository has been archived by the owner on Jan 16, 2023. It is now read-only.
/ node-enum Public archive

A typed enum for TypeScript

License

Notifications You must be signed in to change notification settings

biro456/node-enum

Repository files navigation

@biro456/enum

build status npm package

A typed enum for TypeScript.

Ever wanted to check if a value was a variant of an enum:

enum MyEnum {
	First = 'first',
	Second = 'seconds',
}

const value = MyEnum.First;

if (value instanceof MyEnum) { // error
	console.info('magic');
}

Now you can:

import { Enum } from '@biro456/enum';

type MyEnum = typeof MyEnum;
const MyEnum = Enum.create([
	'First',
	'Second',
]);

const value = MyEnum.First;

if (MyEnum.is(value)) { // works
	console.info('magic');
}

But why?

Mainly because I wanted to see if I could make something ergonomic to use in my projects. So I took several tips from other similar projects.

About

A typed enum for TypeScript

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Contributors 4

  •  
  •  
  •  
  •