random game IDs

This commit is contained in:
Gavin McDonald
2025-04-09 12:11:51 -04:00
parent 3c4b8cf56e
commit 4a802b2d06
4 changed files with 41 additions and 33 deletions

View File

@@ -1,8 +1,10 @@
import { customAlphabet } from 'nanoid';
import getRandomItems from '@/tools/getRandomItems';
const alphabet =
'0123456789abcdefghijklmnopqrstuvwxyz';
const generateID = (length: number = 6) => customAlphabet(alphabet, length);
const generateID = (length: number = 6) => {
return getRandomItems(alphabet.split(''), length).join('');
};
export default generateID;