(options: { minimum: bigint; maximum: bigint }): (self: bigint) => boolean
(self: bigint, options: { minimum: bigint; maximum: bigint }): booleanChecks whether a bigint is between a minimum and maximum value (inclusive).
When to use
Use to test whether a bigint falls inside an inclusive range.
Example (Checking whether a bigint is within bounds)
import { BigInt } from "effect"
import * as assert from "node:assert"
const between = BigInt.between({ minimum: 0n, maximum: 5n })
assert.deepStrictEqual(between(3n), true)
assert.deepStrictEqual(between(-1n), false)
assert.deepStrictEqual(between(6n), false)export const const between: {
(options: {
minimum: bigint
maximum: bigint
}): (self: bigint) => boolean
(
self: bigint,
options: {
minimum: bigint
maximum: bigint
}
): boolean
}
Checks whether a bigint is between a minimum and maximum value (inclusive).
When to use
Use to test whether a bigint falls inside an inclusive range.
Example (Checking whether a bigint is within bounds)
import { BigInt } from "effect"
import * as assert from "node:assert"
const between = BigInt.between({ minimum: 0n, maximum: 5n })
assert.deepStrictEqual(between(3n), true)
assert.deepStrictEqual(between(-1n), false)
assert.deepStrictEqual(between(6n), false)
between: {
(options: {
minimum: bigint
maximum: bigint
}
options: {
minimum: bigintminimum: bigint
maximum: bigintmaximum: bigint
}): (self: bigintself: bigint) => boolean
(self: bigintself: bigint, options: {
minimum: bigint
maximum: bigint
}
options: {
minimum: bigintminimum: bigint
maximum: bigintmaximum: bigint
}): 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<bigint>Provides an Order instance for bigint that allows comparing and sorting BigInt values.
When to use
Use when you need to sort or compare bigint values through APIs that accept
an ordering instance.
Example (Comparing bigints with Order)
import { BigInt } from "effect"
const a = 123n
const b = 456n
const c = 123n
console.log(BigInt.Order(a, b)) // -1 (a < b)
console.log(BigInt.Order(b, a)) // 1 (b > a)
console.log(BigInt.Order(a, c)) // 0 (a === c)
Order)