Skip to content

Commit

Permalink
Refactor sdk-utils to add generateRandomIDNumber function
Browse files Browse the repository at this point in the history
  • Loading branch information
Adammatthiesen committed Dec 10, 2024
1 parent 59e52af commit c6fe139
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions packages/studiocms_core/src/sdk-utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,3 +140,14 @@ export function verifyRank(
export function combineRanks(rank: string, users: SingleRank[]): CombinedRank[] {
return users.map((user) => ({ rank, ...user }));
}

/**
* Generates a random ID number with the specified length for Tags and Categories.
*
* @param length - The length of the random ID number to generate.
*
* @returns A random ID number with the specified length.
*/
export function generateRandomIDNumber(length: number): number {
return Math.floor(Math.random() * 10 ** length);
}

0 comments on commit c6fe139

Please sign in to comment.