UNPKG

cosmo-ui

Version:
11 lines (9 loc) 307 B
export const shortID = (): string => Math.floor((1 + Math.random()) * 0x10000) .toString(16) .substring(1) export const randomID = (): string => { const buf = new Uint8Array(16) crypto.getRandomValues(buf) return Array.from(buf).reduce((id, n) => id + n.toString(16), '') }