mirror of
https://github.com/directus/directus.git
synced 2026-04-25 03:00:53 -04:00
* Add array randomizer * Add sequence randomizer * Add barebones readme * Rename randomIntBetween -> randomInteger * Finish couple new randomizer functions * Add basic tsdoc * Add changeset * Downgrade types/node
9 lines
226 B
TypeScript
9 lines
226 B
TypeScript
/**
|
|
* Return a random item from a given array
|
|
*
|
|
* @param items - Array of any type of things
|
|
*/
|
|
export const randomArray = <T = unknown>(items: readonly T[]): T => {
|
|
return items.at(Math.random() * items.length) as T;
|
|
};
|