Bigint not safe¶
bigintNotSafe is a built‑in scan rule that detects bigint values that fall outside JavaScript’s safe integer range (from Number.MIN_SAFE_INTEGER to Number.MAX_SAFE_INTEGER).
When the value is a bigint and lies outside this range, the rule emits a warn‑level bigint.not.safe scan event containing the observed value and the safe bounds. If the value is not a bigint or lies within the safe range, no events are emitted.
Signature¶
export const bigintNotSafe: ScanRule (raw: unknown, path: FieldPath) => JaneEvent[]
Events¶
| Event code | Description |
|---|---|
bigint.not.safe |
BigInt value is outside JavaScript’s safe integer range. |
Design rationale¶
- Detects bigint values that cannot be safely represented as JavaScript numbers.
- Surfaces interoperability hazards for systems that assume numeric values remain within the safe integer range.
- Emits a warning when the value is less than
Number.MIN_SAFE_INTEGERor greater thanNumber.MAX_SAFE_INTEGER. - Provides metadata (
{ value, maxSafe, minSafe }) for policy and analysis. - Performs no mutation or transformation of the input.
Invoke¶
bigintNotSafe runs automatically whenever the scan stage is enabled.
Activation methods:
- Enable scan explicitly:
jane.value(input).scan(). - Use a mode that enables scan:
strict()enables scan by default.moderate()andlax()do not enable scan unless.scan()is called.- Enable scan with policy:
jane.value(input).withPolicy({ mode: 'strict' }).
If scan is not enabled or the value is not a bigint, bigintNotSafe does not run and no safe‑range detection occurs.
Examples¶
Bigint outside safe range¶
const result = bigintNotSafe(9007199254740993n, "$");
// → [ JaneEvent{ kind: "warn", code: "bigint.not.safe", ... } ]
Bigint within safe range¶
const result = bigintNotSafe(100n, "$");
// → []