effect-io-ai

Package: effect
Module: BigInt

BigInt.fromString

Parses a string into a bigint safely.

When to use

Use to parse a string as a bigint without throwing on invalid input.

Details

If the string is empty or contains characters that cannot be converted into a bigint, it returns Option.none().

Example (Parsing strings as bigints)

import { BigInt } from "effect"

BigInt.fromString("42") // Option.some(42n)
BigInt.fromString(" ") // Option.none()
BigInt.fromString("a") // Option.none()

See

Signature

declare const fromString: (s: string) => Option.Option<bigint>

Source

Since v2.4.12