Hyperlinkv0.8.0-beta.28

Schema

Source effect/Schema.ts:1072526 lines
export interface DurationFromNanos extends decodeTo<Duration, BigInt> {
  readonly "Rebuild": DurationFromNanos
}

const bigint0 = globalThis.BigInt(0)

/**
 * Schema that decodes a non-negative `bigint` into a
 * `Duration`, treating the bigint as nanoseconds.
 *
 * **Details**
 *
 * Decoding:
 * A non-negative `bigint` representing nanoseconds is decoded as a `Duration`.
 *
 * Encoding:
 * Finite durations are encoded as a non-negative `bigint` number of nanoseconds.
 * Encoding fails when the duration cannot be represented as nanoseconds, such as
 * `Duration.infinity`.
 *
 * @category Duration
 * @since 3.10.0
 */
export const DurationFromNanos: DurationFromNanos = BigInt.check(isGreaterThanOrEqualToBigInt(bigint0)).pipe(
  decodeTo(Duration, SchemaTransformation.durationFromNanos)
)