export const logNow = (startTime: number, ...aargs: any[]) => { const color = (milliseconds: number) => { if (milliseconds < 7) return "color: #000000" if (milliseconds > 10) return "color: #840000" return "color: #FA7238" } const ms = performance.now() - startTime console.log(`⏱️%c ${ms}ms`, color(ms), aargs) } export const storeActionTimer = ({ name, // name of the action args, // array of parameters passed to the action after, // hook after the action returns or resolves onError, // hook if the action throws or rejects }: // any because unique for you and because snippet whatever any) => { const now = performance.now onError((err: any) => { logNow(now, `${name}()`, args) console.trace(err) }) after(() => { logNow(now, `${name}()`, args) }) }