UNPKG

@gamepark/rules-api

Version:

API to implement the rules of a board game

37 lines 1.08 kB
/** * 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 function getEnumKeys(enumType) { return Object.keys(enumType).filter(key => isNaN(Number(key))); } /** * 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 function getEnumValues(enumType) { return getEnumKeys(enumType).map(key => enumType[key]); } /** * 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 function getEnumEntries(enumType) { return getEnumKeys(enumType).map(key => [key, enumType[key]]); } /** * @deprecated Use getEnumValues instead */ export function isEnumValue(value) { return typeof value !== 'string'; } //# sourceMappingURL=enum.util.js.map