Skip to content

Latest commit

 

History

History
26 lines (20 loc) · 534 Bytes

README.md

File metadata and controls

26 lines (20 loc) · 534 Bytes

parse-bigint

A single function, parseBigInt, that takes a number-like value and returns a BigInt with support for scientific notation, underscores, commas, and base prefixes.

Installation

npm install parse-bigint

Example

import { parseBigInt } from 'parse-bigint';

parseBigInt(10); // 10n
parseBigInt('10'); // 10n
parseBigInt('10.123e3'); // 10123n
parseBigInt('10_123'); // 10123n
parseBigInt('10,123'); // 10123n
parseBigInt('0x10'); // 16n
parseBigInt('0b10'); // 2n
parseBigInt('0o10'); // 8n