🌳
pt0/deployF/cliF/cliTimerCtxF.mts
3type CliTimerStore = { startTime: number }
5const cliTimerCtx = genContext<CliTimerStore>('cliTimer')
7export const initCliTimer = () => {
8 if (cliTimerCtx.getStore()) return
9 cliTimerCtx.enterWith({startTime: Date.now()}) // ctx:clear
12export const fmtElapsed = (): string => {
13 const store = cliTimerCtx.getStore()
14 if (!store) return ''
15 const sec = (Date.now() - store.startTime) / 1000
16 return `${sec.toFixed(1)}s `
19export const logElapsed = (msg: string) => console.log(fmtElapsed() + msg)