@internal
| 65 | |
| 66 | /** @internal */ |
| 67 | class ClockImpl implements Clock.Clock { |
| 68 | readonly [ClockTypeId]: Clock.ClockTypeId = ClockTypeId |
| 69 | |
| 70 | unsafeCurrentTimeMillis(): number { |
| 71 | return Date.now() |
| 72 | } |
| 73 | |
| 74 | unsafeCurrentTimeNanos(): bigint { |
| 75 | return processOrPerformanceNow() |
| 76 | } |
| 77 | |
| 78 | currentTimeMillis: Effect.Effect<number> = core.sync(() => this.unsafeCurrentTimeMillis()) |
| 79 | |
| 80 | currentTimeNanos: Effect.Effect<bigint> = core.sync(() => this.unsafeCurrentTimeNanos()) |
| 81 | |
| 82 | scheduler(): Effect.Effect<Clock.ClockScheduler> { |
| 83 | return core.succeed(globalClockScheduler) |
| 84 | } |
| 85 | |
| 86 | sleep(duration: Duration.Duration): Effect.Effect<void> { |
| 87 | return core.async<void>((resume) => { |
| 88 | const canceler = globalClockScheduler.unsafeSchedule(() => resume(core.void), duration) |
| 89 | return core.asVoid(core.sync(canceler)) |
| 90 | }) |
| 91 | } |
| 92 | } |
| 93 | |
| 94 | /** @internal */ |
| 95 | export const make = (): Clock.Clock => new ClockImpl() |
nothing calls this directly
no test coverage detected