Skip to content

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

Description

@LMaxence

Context

Follow-up from review of #55. As noted there:

The Hellog class is getting a bit bigger than what I'd like it to be [...] I'd like to move the timers and metas into isolated classes handling their logic and serde layers

The Hellog class now owns timer state (_timers map, time/timeEnd) and meta resolution/merging (_resolveMeta, child/log merge logic) inline. These should be extracted into dedicated classes that own their logic and serialization.

Proposed shape

  • lib/timer.ts → HellogTimer: owns the Map<string, bigint> timer store, start(label), end(label): number | undefined (elapsed ms, one-shot), and a static format(label, ms) for the duration serialization.
  • lib/meta.ts → HellogMeta: owns meta resolution and parent/child merging — resolve(), merge(extra), child(extra) — replacing Hellog._resolveMeta and the inline merge logic in child/_log.
  • Hellog delegates to both; public behavior (child meta merging, timer durations) unchanged.
  • Export both from lib/index.ts; add lib/timer.spec.ts and lib/meta.spec.ts.

Behavior must remain identical to today.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions