:: features
Why Clock?
Testable Time
Replace real time with a fake clock in tests. No more flaky time-dependent tests.
Frozen Clock
Pin time to a specific instant for deterministic snapshot testing.
Virtual Advance
Advance time programmatically. Test timeouts, debounces, and scheduling without waiting.
Port-Based
Clock is a port. Production uses real time, tests use fake time. Same interface.
Timer Support
setTimeout and setInterval that respect the clock implementation. Controllable in tests.
Duration Types
Type-safe duration arithmetic. No more raw millisecond math.
:: ecosystem
Part of the HexDI Stack
Clock integrates seamlessly with the HexDI dependency injection ecosystem. Use it standalone or compose it with other libraries.
Explore HexDI