@pragma-web-utils/bigint-utils
TypeScript icon, indicating that this package has built-in type declarations

0.2.0 • Public • Published

BigInt utils

Types

type BI = bigint
type BIish = BI | string | number

Convert

###toDecimals

Signature

function toDecimals(amount: BIish, decimals: number): string {}

Description

Convert BIish to string by provided decimals

###fromDecimals

Signature

function fromDecimals(
  amount: string,
  decimals: number,
  options?: Partial<BIParseOption>,
): BI {}

Description

Convert string to BIish by provided decimals

Parse options

type BIParseOption = {
  isDecimalsCountOverflowPossible: boolean // throw error or ignore if string has more symbols than provided decimals
}

Default options

type BIParseOption = {
  isDecimalsCountOverflowPossible: true
}

###fromBIish

Signature

function fromBIish(amount: BIish): BI {}

Description

Convert BIish to strict BI

###fromBP

Signature

function fromBP(percentInBP: BI, percentDecimals = 2): number {}

Description

Convert BigPercent to number, by default percent decimals equal 2

Formatting

formattedNumber

Signature

function formattedNumber(
  value: number,
  formatOptions?: Intl.NumberFormatOptions,
): string {}

Description

Format number by formatOptions. By default:

const defaultOptions = {
  style: 'decimal',
  minimumFractionDigits: 0,
  maximumFractionDigits: 2,
}

###formattedDecimals

Signature

function formattedDecimals(
  amountTKN: BIish,
  decimals: number,
  formatOptions?: Intl.NumberFormatOptions,
): string {}

Description

Format BI by decimals and formatOptions. By default:

const defaultOptions = {
  style: 'decimal',
  minimumFractionDigits: 0,
  maximumFractionDigits: 2,
}

BIMath

###BIMath.min

Signature

BIMath.min(...values: BI[]): BI

Description

Return min of provided values

###BIMath.max

Signature

BIMath.max(...values: BI[]): BI

Description

Return max of provided values

Readme

Keywords

Package Sidebar

Install

npm i @pragma-web-utils/bigint-utils

Weekly Downloads

0

Version

0.2.0

License

MIT

Unpacked Size

11.5 kB

Total Files

15

Last publish

Collaborators

  • martushka
  • jumojet5