stutiagrawal's picture
adding the ui files
a45ece3
Raw
History Blame Contribute Delete
291 Bytes
const alphabet = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz-'
export function nanoid(size = 12): string {
let id = ''
const bytes = crypto.getRandomValues(new Uint8Array(size))
for (let i = 0; i < size; i++) {
id += alphabet[bytes[i] & 63]
}
return id
}