| import * as effect from "./internal/effect.js"; | |
| /** | |
| * Context reference for the active time service in the environment. | |
| * | |
| * **When to use** | |
| * | |
| * Use when you need to access or provide the full time service, including sleep | |
| * operations, rather than a single timestamp accessor. | |
| * | |
| * **Example** (Accessing the Clock service) | |
| * | |
| * ```ts | |
| * import { Clock, Effect } from "effect" | |
| * | |
| * const program = Effect.gen(function*() { | |
| * const clock = yield* Clock.Clock | |
| * return clock.currentTimeMillisUnsafe() | |
| * }) | |
| * ``` | |
| * | |
| * @see {@link clockWith} for using the current Clock service inside an effect | |
| * @see {@link currentTimeMillis} for reading the current time in milliseconds | |
| * @see {@link currentTimeNanos} for reading the current time in nanoseconds | |
| * | |
| * @category references | |
| * @since 2.0.0 | |
| */ | |
| export const Clock = effect.ClockRef; | |
| /** | |
| * Accesses the current Clock service and uses it to run the provided function. | |
| * | |
| * **When to use** | |
| * | |
| * Use when you need the full Clock service interface to perform multiple time | |
| * operations or call unsafe variants within a single effect. | |
| * | |
| * **Example** (Using the current Clock service) | |
| * | |
| * ```ts | |
| * import { Clock, Effect } from "effect" | |
| * | |
| * const program = Clock.clockWith((clock) => | |
| * Effect.sync(() => { | |
| * const currentTime = clock.currentTimeMillisUnsafe() | |
| * console.log(`Current time: ${currentTime}`) | |
| * return currentTime | |
| * }) | |
| * ) | |
| * ``` | |
| * | |
| * @see {@link Clock} for the service reference | |
| * @see {@link currentTimeMillis} for convenience accessor that returns milliseconds | |
| * @see {@link currentTimeNanos} for convenience accessor that returns nanoseconds | |
| * @category constructors | |
| * @since 2.0.0 | |
| */ | |
| export const clockWith = effect.clockWith; | |
| /** | |
| * Returns an Effect that succeeds with the current time in milliseconds. | |
| * | |
| * **When to use** | |
| * | |
| * Use to read wall-clock time from the active Clock service with millisecond | |
| * precision. | |
| * | |
| * **Example** (Reading milliseconds) | |
| * | |
| * ```ts | |
| * import { Clock, Effect } from "effect" | |
| * | |
| * const program = Effect.gen(function*() { | |
| * const currentTime = yield* Clock.currentTimeMillis | |
| * console.log(`Current time: ${currentTime}ms`) | |
| * return currentTime | |
| * }) | |
| * ``` | |
| * | |
| * @see {@link currentTimeNanos} for nanosecond precision | |
| * @see {@link clockWith} for accessing the full Clock service | |
| * | |
| * @category constructors | |
| * @since 2.0.0 | |
| */ | |
| export const currentTimeMillis = effect.currentTimeMillis; | |
| /** | |
| * Returns an Effect that succeeds with the current time in nanoseconds. | |
| * | |
| * **When to use** | |
| * | |
| * Use to read wall-clock time from the active `Clock` service with nanosecond | |
| * precision. | |
| * | |
| * **Example** (Reading nanoseconds) | |
| * | |
| * ```ts | |
| * import { Clock, Effect } from "effect" | |
| * | |
| * const program = Effect.gen(function*() { | |
| * const currentTime = yield* Clock.currentTimeNanos | |
| * console.log(`Current time: ${currentTime}ns`) | |
| * return currentTime | |
| * }) | |
| * ``` | |
| * | |
| * @category constructors | |
| * @since 2.0.0 | |
| */ | |
| export const currentTimeNanos = effect.currentTimeNanos; | |
| //# sourceMappingURL=Clock.js.map |
Xet Storage Details
- Size:
- 3.08 kB
- Xet hash:
- 9c2247d66831c277bbd8d4f727e58d2c93f4808b12bee25122063ccfe8cd2d9a
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.