@gamepark/rules-api
Version:
API to implement the rules of a board game
35 lines (34 loc) • 1.13 kB
TypeScript
/**
* Generic type for typescript enum objects
*/
export type Enum<E> = Record<keyof E, number | string> & {
[k: number]: string;
};
/**
* Get the keys of an enum at run time.
* Credits to https://github.com/tranvansang/enum-for
*
* @param enumType The enumeration
* @returns returns the list of the keys of the enum
*/
export declare function getEnumKeys<E extends Enum<E>>(enumType: E): Array<keyof E>;
/**
* Get the values of an enum at run time.
* Credits to https://github.com/tranvansang/enum-for
*
* @param enumType The enumeration
* @returns returns the list of the values of the enum
*/
export declare function getEnumValues<E extends Enum<E>>(enumType: E): Array<E[keyof E]>;
/**
* Get the entries of an enum at run time.
* Credits to https://github.com/tranvansang/enum-for
*
* @param enumType The enumeration
* @returns returns the list of the entries of the enum
*/
export declare function getEnumEntries<E extends Enum<E>>(enumType: E): Array<[keyof E, E[keyof E]]>;
/**
* @deprecated Use getEnumValues instead
*/
export declare function isEnumValue<T>(value: string | T): value is T;