UNPKG

@fivem-ts/shared

Version:

FiveM Typescript wrapper shared part

18 lines (17 loc) 560 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getRandomEnumKey = getRandomEnumKey; /** * Returns a random key from the given enum type. * * @template T * * @param {T} enumType - The enum type from which to select a random key * * @return {keyof T} A randomly selected key from the provided enum type. */ function getRandomEnumKey(enumType) { const keys = Object.keys(enumType).filter(key => isNaN(Number(key))); const randomIndex = Math.floor(Math.random() * keys.length); return keys[randomIndex]; }