Documentation
¶
Overview ¶
Package jsclock is the process clock of JavaScript's Date.now() and performance.now(), with a replaceable source. Upstream tests replace both with vi.spyOn; Go keeps the replacement here so telemetry adapters read the same clock.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DateNow ¶
func DateNow() float64
DateNow is Date.now(): whole milliseconds since the Unix epoch.
func PerformanceNow ¶
func PerformanceNow() float64
PerformanceNow is performance.now(): fractional milliseconds on a monotonic clock since process start.
Types ¶
type Mock ¶
type Mock struct {
// contains filtered or unexported fields
}
Mock is a replacement for one clock, set like vi.spyOn(...).mockReturnValue.
func MockDateNow ¶
MockDateNow replaces Date.now() with a constant that returns initial until Set. The returned restore reinstalls the real clock, as vi.restoreAllMocks does.
func MockPerformanceNow ¶
MockPerformanceNow replaces performance.now() like MockDateNow.