(that: Duration): (self: Duration) => Duration
(self: Duration, that: Duration): DurationReturns the larger of two Durations.
Example (Selecting the longer duration)
import { Duration } from "effect"
const longer = Duration.max(Duration.seconds(5), Duration.seconds(3))
console.log(Duration.toSeconds(longer)) // 5ordering
Source effect/Duration.ts:12554 lines
export const const max: {
(that: Duration): (self: Duration) => Duration
(self: Duration, that: Duration): Duration
}
Returns the larger of two Durations.
Example (Selecting the longer duration)
import { Duration } from "effect"
const longer = Duration.max(Duration.seconds(5), Duration.seconds(3))
console.log(Duration.toSeconds(longer)) // 5
max: {
(that: Duration(parameter) that: {
value: DurationValue;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
toString: () => string;
toJSON: () => unknown;
}
that: Duration): (self: Duration(parameter) self: {
value: DurationValue;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
toString: () => string;
toJSON: () => unknown;
}
self: Duration) => Duration
(self: Duration(parameter) self: {
value: DurationValue;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
toString: () => string;
toJSON: () => unknown;
}
self: Duration, that: Duration(parameter) that: {
value: DurationValue;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
toString: () => string;
toJSON: () => unknown;
}
that: Duration): Duration
} = import orderorder.const max: <A>(O: Order<A>) => {
(that: A): (self: A) => A
(self: A, that: A): A
}
Returns the maximum of two values according to the given order. If they are equal, returns the first argument.
When to use
Use when you need to select the larger of two values according to an
Order.
Details
Returns the value that compares as greater than or equal to the other value.
If values are equal, the first argument is returned.
Example (Selecting the maximum value)
import { Order } from "effect"
const maxNumber = Order.max(Order.Number)
console.log(maxNumber(1, 2)) // 2
console.log(maxNumber(2, 1)) // 2
console.log(maxNumber(1, 1)) // 1
max(const Order: order.Order<Duration>Provides an Order instance for comparing Duration values.
Details
NegativeInfinity < any finite value < Infinity.
Example (Sorting durations)
import { Duration } from "effect"
const durations = [
Duration.seconds(3),
Duration.seconds(1),
Duration.seconds(2)
]
const sorted = durations.sort((a, b) => Duration.Order(a, b))
console.log(sorted.map(Duration.toSeconds)) // [1, 2, 3]
Order)