_comuns/src/aleatorio.ts
2024-06-02 16:20:44 -03:00

6 lines
238 B
TypeScript

const alfabeto = "ABCDEFGHIJKLMNOPQRSTUVWXYZ".split("")
export const aleatorio = (tamanho?: number) =>
`eli-${Array.from({ length: tamanho || 8 })
.map(() => alfabeto[((999 * Math.random()) | 0) % alfabeto.length])
.join("")}`