BigNum
constBigNum:object
Defined in: Data/BigNum.ts:18
Safe conversion and arithmetic utilities for arbitrary-precision integers (bigint).
All functions are pure and data-last to compose cleanly with pipe.
Type Declaration
Section titled “Type Declaration”abs: (
a) =>bigint
Returns absolute value of a bigint.
Parameters
Section titled “Parameters”bigint
Returns
Section titled “Returns”bigint
Example
Section titled “Example”add: (
b) => (a) =>bigint
Adds b to a. Data-last curried signature: add(b)(a) = a + b.
Parameters
Section titled “Parameters”bigint
Returns
Section titled “Returns”(a) => bigint
Example
Section titled “Example”clamp: (
min,max) => (a) =>bigint
Clamps a between min and max (inclusive).
Parameters
Section titled “Parameters”bigint
bigint
Returns
Section titled “Returns”(a) => bigint
Example
Section titled “Example”div: (
b) => (a) =>Maybe<bigint>
Divides a by b. Returns None if b is 0n.
Parameters
Section titled “Parameters”bigint
Returns
Section titled “Returns”(a) => Maybe<bigint>
Example
Section titled “Example”from:
object
from.number
Section titled “from.number”number: (
n) =>Maybe<bigint>
Safely converts a number into a bigint. Returns None for floats, NaN, or non-safe integers.
Parameters
Section titled “Parameters”number
Returns
Section titled “Returns”Maybe<bigint>
Example
Section titled “Example”from.string
Section titled “from.string”string: (
s) =>Maybe<bigint>
Safely parses a string into a bigint. Returns None if parsing fails.
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”Maybe<bigint>
Example
Section titled “Example”inRange
Section titled “inRange”inRange: (
start,end) => (a) =>boolean
Returns true if a is in the range [start, end) (inclusive start, exclusive end).
Parameters
Section titled “Parameters”bigint
bigint
Returns
Section titled “Returns”(a) => boolean
Example
Section titled “Example”is:
object
is.even
Section titled “is.even”even: (
b) =>boolean
Returns true when the bigint is an even integer.
Parameters
Section titled “Parameters”bigint
Returns
Section titled “Returns”boolean
Example
Section titled “Example”is.negative
Section titled “is.negative”negative: (
b) =>boolean
Returns true when the bigint is strictly less than zero (0n).
Parameters
Section titled “Parameters”bigint
Returns
Section titled “Returns”boolean
Example
Section titled “Example”is.odd
Section titled “is.odd”odd: (
b) =>boolean
Returns true when the bigint is an odd integer.
Parameters
Section titled “Parameters”bigint
Returns
Section titled “Returns”boolean
Example
Section titled “Example”is.positive
Section titled “is.positive”positive: (
b) =>boolean
Returns true when the bigint is strictly greater than zero (0n).
Parameters
Section titled “Parameters”bigint
Returns
Section titled “Returns”boolean
Example
Section titled “Example”is.zero
Section titled “is.zero”zero: (
b) =>boolean
Returns true when the bigint is equal to zero (0n).
Parameters
Section titled “Parameters”bigint
Returns
Section titled “Returns”boolean
Example
Section titled “Example”max: (
b) => (a) =>bigint
Returns the maximum of a and b.
Parameters
Section titled “Parameters”bigint
Returns
Section titled “Returns”(a) => bigint
Example
Section titled “Example”min: (
b) => (a) =>bigint
Returns the minimum of a and b.
Parameters
Section titled “Parameters”bigint
Returns
Section titled “Returns”(a) => bigint
Example
Section titled “Example”mod: (
b) => (a) =>Maybe<bigint>
Computes remainder of a / b. Returns None if b is 0n.
Parameters
Section titled “Parameters”bigint
Returns
Section titled “Returns”(a) => Maybe<bigint>
Example
Section titled “Example”mul: (
b) => (a) =>bigint
Multiplies a by b. Data-last curried signature: mul(b)(a) = a * b.
Parameters
Section titled “Parameters”bigint
Returns
Section titled “Returns”(a) => bigint
Example
Section titled “Example”sub: (
b) => (a) =>bigint
Subtracts b from a. Data-last curried signature: sub(b)(a) = a - b.
Parameters
Section titled “Parameters”bigint
Returns
Section titled “Returns”(a) => bigint
Example
Section titled “Example”to:
object
to.number
Section titled “to.number”number: (
b) =>Maybe<number>
Safely converts a bigint to a number. Returns None if the value is outside JavaScript’s safe integer range.
Parameters
Section titled “Parameters”bigint
Returns
Section titled “Returns”Maybe<number>