MCPcopy Index your code
hub / github.com/triggerdotdev/trigger.dev / PreciseWallClock

Class PreciseWallClock

packages/core/src/v3/clock/preciseWallClock.ts:9–46  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7};
8
9export class PreciseWallClock implements Clock {
10 private _origin: {
11 clockTime: ClockTime;
12 preciseDate: PreciseDate;
13 };
14
15 get #originClockTime() {
16 return this._origin.clockTime;
17 }
18
19 get #originPreciseDate() {
20 return this._origin.preciseDate;
21 }
22
23 constructor(options: PreciseWallClockOptions = {}) {
24 this._origin = {
25 clockTime: options.origin ?? process.hrtime(),
26 preciseDate: options.now ?? new PreciseDate(),
27 };
28 }
29
30 preciseNow(): [number, number] {
31 const elapsedHrTime = process.hrtime(this.#originClockTime);
32 const elapsedNanoseconds = BigInt(elapsedHrTime[0]) * BigInt(1e9) + BigInt(elapsedHrTime[1]);
33
34 const preciseDate = new PreciseDate(this.#originPreciseDate.getFullTime() + elapsedNanoseconds);
35 const dateStruct = preciseDate.toStruct();
36
37 return [dateStruct.seconds, dateStruct.nanos];
38 }
39
40 reset() {
41 this._origin = {
42 clockTime: process.hrtime(),
43 preciseDate: new PreciseDate(),
44 };
45 }
46}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…