random str option

This commit is contained in:
Satria 2026-03-23 22:12:02 +07:00
commit 0a50728469

View file

@ -32,9 +32,9 @@ export function timeAgo(unixTimestamp: number): string {
return Math.floor(seconds) + " seconds ago";
}
export function randomStr(length: number): string {
export function randomStr(length: number, withNumbers = true): string {
let result = '';
const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ123456789'.toUpperCase();
const characters = ('ABCDEFGHIJKLMNOPQRSTUVWXYZ' + (withNumbers ? '123456789' : '')).toUpperCase();
const charactersLength = characters.length;
let counter = 0;
while (counter < length) {