UNPKG

@fivem-ts/shared

Version:

FiveM Typescript wrapper shared part

19 lines (18 loc) 652 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getRandomEnumEntry = getRandomEnumEntry; const maths_1 = require("../maths"); /** * Returns a random entry from the given enum type. * * @template T * * @param {object} enumType - The enum type from which to select a random entry. * * @return {[keyof T, T[keyof T]]} - An array containing the random key-value pair from the enum. */ function getRandomEnumEntry(enumType) { const values = Object.entries(enumType).filter(([key]) => isNaN(Number(key))); const randomIndex = (0, maths_1.getRandomInt)(0, values.length); return values[randomIndex]; }