export function Enum < V extends string > ( ... values ) ; export function Enum < T extends { [ _ ] : V ; } , V extends string > ( definition ) ; export function Enum ( ... values ) { if ( typeof values [ 0 ] === "string" ) { const result = { } ; for ( const value of values ) { result [ value ] = value ; } return result ; } else { return values [ 0 ] ; } } export type Enum < T extends object > = T [ keyof T ] ; export namespace Enum { export function ofKeys < T extends { [ _ ] : any ; } > ( e ) { const result = { } ; for ( const key of Object . keys ( e ) ) { result [ key ] = key ; } return result ; } export function keys < T extends { [ _ ] : any ; } > ( e ) { return Object . keys ( e ) as Array < keyof T > ; } export function values < T extends { [ _ ] : any ; } > ( e ) { const result = [ ] ; for ( const key of Object . keys ( e ) ) { result . push ( e [ key ] ) ; } return result ; } export function isType < T extends { [ _ ] : any ; } > ( e , value ) { return values ( e ) . indexOf ( value ) !== - 1 ; } }