Skip to content

Get keys and values of TypeScript enums during run-time

Notifications You must be signed in to change notification settings

suzanne-lee/enum-util

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

enum-util

Only works with TypeScript enums.

Use this to get keys, and values of your enums during run-time.

Installation

npm install --save enum-util

Usage

import * as enumUtil from "enum-util";
enum Bar {
    B = "b",
    D = "d",
    F = "f"
}
enumUtil.getKeys(Bar); //["B", "D", "F"]
enumUtil.getValues(Bar); //["b", "d", "f"]
enumUtil.extractValues(Bar, ["B", "b", "D", "d", "F", "f"]); //["b", "d", "f"]

License

Do what you want with this as long as you do no evil.

About

Get keys and values of TypeScript enums during run-time

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • TypeScript 100.0%