INNER CODE UNIT · TypeScript
generateId
beeequeue/yuna · src/utils/index.ts:130
export const generateId = () => {
const chars = "abcdefghijklmnopqrstuvwxyz1234567890"
let id = ""
for (let i = 0; i < 8; i++) {
id += chars[Math.round(Math.random() * chars.length - 1)]
}
return id
}
export const hasKey = (obj: any, value: any) => Object.keys(obj).includes(value)
export const clamp = (x: number, min: number, max: number) =>
Math.max(min, Math.min(x, max))
export const enumToArray = <E>(Enum: E): E[] => Object.values(Enum)