export function memo {}, S>( func: T, lifespan: number = 5 * 60 * 1000, keyDelegate?: (...args: any[]) => string, ): T { const cache: { [key: string]: { value: S; timestamp: number } } = {}; return ((...args: any[]): S => { const key: string = (keyDelegate ? keyDelegate(...args) : args?.[0]?.toString()) ?? ''; const now = Date.now(); if (!cache[key] || now - cache[key].timestamp > lifespan) { cache[key] = { value: func(...args) as S, timestamp: now, }; } return cache[key].value; }) as unknown as T; } export function createRandomString(length:number = 6):string { const maxRandStringVal = parseInt(''.padEnd(length, 'z'), 36); return Math.floor(Math.random() * maxRandStringVal).toString(36).toUpperCase(); } export const brandColours = { dark: '#14111C', mid: '#CBCACB', light: '#FBF8FC', white: '#FFFFFF', black: '#000000', primary: '#CA00E7', secondary: '#FFB527', tertiary: '#6ED500', danger: '#CA3211', };