Skip to content

refactor: extract Timer and Meta into isolated classes#57

Merged
LMaxence merged 1 commit into
mainfrom
refactor/timers-meta-classes
Jun 27, 2026
Merged

refactor: extract Timer and Meta into isolated classes#57
LMaxence merged 1 commit into
mainfrom
refactor/timers-meta-classes

Conversation

@LMaxence

Copy link
Copy Markdown
Owner

Summary

Follow-up to #55. Extracts the timer and meta responsibilities out of the growing Hellog class into dedicated classes that own their logic and serialization, per the review note on #55.

  • lib/timer.tsHellogTimer — owns the Map<string, bigint> timer store, start(label), end(label): number | undefined (one-shot), and a static format(label, ms) for duration serialization.
  • lib/meta.tsHellogMeta — owns meta resolution and parent/child merging via resolve(), merge(extra), child(extra), replacing Hellog._resolveMeta and the inline merge logic in child / _log.
  • Hellog now delegates to both. Public behavior (child meta merging, dynamic meta, timer durations, durationMs) is unchanged.
  • Both classes exported from lib/index.ts; added lib/timer.spec.ts and lib/meta.spec.ts.

Closes #56.

Notes

Stacked on #55 — this branch builds on feat/child-loggers-dx, so until #55 merges the diff against main also shows #55's changes. Merge after #55.

Test plan

  • npm run build — clean under @tsconfig/strictest
  • npm test — 45/45 pass (32 existing + 13 new timer/meta specs)
  • npm run lint — oxlint clean
  • npm run format:check — oxfmt clean

🤖 Generated with Claude Code

Move the timer store/elapsed logic into HellogTimer (lib/timer.ts) and meta
resolution/merging into HellogMeta (lib/meta.ts). Hellog now delegates to both;
public behavior (child meta merging, timer durations) is unchanged.

Closes #56.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@LMaxence LMaxence merged commit 69fa619 into main Jun 27, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

refactor: extract timer and meta logic from Hellog into isolated classes

1 participant