Package: effect
Module: Match
Matches values of type bigint.
When to use
Use to match primitive bigint values.
Details
This predicate refines unknown values to bigints, allowing pattern matching on bigint types. BigInts are used for representing integers with arbitrary precision.
Example (Matching bigint values)
import { Match } from "effect"
const processLargeNumber = Match.type<unknown>().pipe(
Match.when(Match.bigint, (big) => {
if (big > 9007199254740991n) {
return `Large integer: ${big.toString()}`
}
return `BigInt: ${big.toString()}`
}),
Match.when(Match.number, (num) => `Regular number: ${num}`),
Match.orElse(() => "Not a numeric type")
)
console.log(processLargeNumber(123n)) // "BigInt: 123"
console.log(processLargeNumber(9007199254740992n)) // "Large integer: 9007199254740992"
console.log(processLargeNumber(123)) // "Regular number: 123"
console.log(processLargeNumber("123")) // "Not a numeric type"
See
number for matching primitive number valuesSignature
declare const bigint: Predicate.Refinement<unknown, bigint>
Since v4.0.0