(options: { minimum: Duration; maximum: Duration }): (
self: Duration
) => boolean
(
self: Duration,
options: { minimum: Duration; maximum: Duration }
): booleanReturns true if a Duration is greater than or equal to minimum and
less than or equal to maximum, according to Duration.Order.
When to use
Use to test whether a duration is inside an inclusive range.
Details
Both bounds are inclusive and compared with Duration.Order.
Gotchas
The bounds are not normalized. If minimum is greater than maximum, the
predicate returns false for every duration.
Example (Checking duration ranges)
import { Duration } from "effect"
const isInRange = Duration.between(Duration.seconds(3), {
minimum: Duration.seconds(2),
maximum: Duration.seconds(5)
})
console.log(isInRange) // trueexport const const between: {
(options: {
minimum: Duration
maximum: Duration
}): (self: Duration) => boolean
(
self: Duration,
options: {
minimum: Duration
maximum: Duration
}
): boolean
}
Returns true if a Duration is greater than or equal to minimum and
less than or equal to maximum, according to Duration.Order.
When to use
Use to test whether a duration is inside an inclusive range.
Details
Both bounds are inclusive and compared with Duration.Order.
Gotchas
The bounds are not normalized. If minimum is greater than maximum, the
predicate returns false for every duration.
Example (Checking duration ranges)
import { Duration } from "effect"
const isInRange = Duration.between(Duration.seconds(3), {
minimum: Duration.seconds(2),
maximum: Duration.seconds(5)
})
console.log(isInRange) // true
between: {
(options: { minimum: Duration; maximum: Duration }options: { minimum: Duration(property) minimum: {
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;
}
minimum: Duration; maximum: Duration(property) maximum: {
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;
}
maximum: 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) => boolean
(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, options: { minimum: Duration; maximum: Duration }options: { minimum: Duration(property) minimum: {
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;
}
minimum: Duration; maximum: Duration(property) maximum: {
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;
}
maximum: Duration }): boolean
} = import orderorder.const isBetween: <A>(O: Order<A>) => {
(options: { minimum: A; maximum: A }): (
self: A
) => boolean
(
self: A,
options: { minimum: A; maximum: A }
): boolean
}
Checks whether a value is between a minimum and a maximum (inclusive) according to the given order.
When to use
Use when you need range checks that respect domain-specific ordering, such as
dates, versions, or custom priorities, instead of JavaScript numeric
comparison.
Details
Returns true when the value is greater than or equal to minimum and less
than or equal to maximum. Values outside the range return false. Both
bounds are inclusive.
Example (Checking ranges)
import { Order } from "effect"
const betweenNumber = Order.isBetween(Order.Number)
console.log(betweenNumber(5, { minimum: 1, maximum: 10 })) // true
console.log(betweenNumber(1, { minimum: 1, maximum: 10 })) // true
console.log(betweenNumber(10, { minimum: 1, maximum: 10 })) // true
console.log(betweenNumber(0, { minimum: 1, maximum: 10 })) // false
console.log(betweenNumber(11, { minimum: 1, maximum: 10 })) // false
isBetween(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)