Skip to content

Parses a number-like value into a BigInt with support for scientific notation, underscores, commas, and base prefixes.

Notifications You must be signed in to change notification settings

ryangoree/parse-bigint

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Parses a number-like value into a BigInt with support for scientific notation, underscores, commas, and base prefixes.

Resources

Stars

Watchers

Forks

Packages

No packages published