🚀 DAY 5 OF LAUNCH WEEK: Introducing Socket Firewall Enterprise.Learn more →
Socket
Book a DemoInstallSign in
Socket

@cennznet/util

Package Overview
Dependencies
Maintainers
1
Versions
55
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@cennznet/util

utils for CENNZnet api

latest
Source
npmnpm
Version
1.5.3
Version published
Maintainers
1
Created
Source

CENNZNet Util

Utils for CENNZNet

Functions

  • formatUnits
  • isSafeInteger
  • parseUnits
  • stripEndZero
  • toFixed

Variables

<Const> INTEGER

â—Ź INTEGER: RegExp = /^\d+$/

Defined in packages/util/src/is/integer.ts:15

<Const> STRIP_ZERO

â—Ź STRIP_ZERO: RegExp = /^(.?)(0)$/

Defined in packages/util/src/format/stripEndZero.ts:17

Functions

formatUnits

â–¸ formatUnits(unValue: BN | number | string, decimals: number): string

Defined in packages/util/src/unit/formatUnits.ts:25

format a amount from unit un to decimals passed in.

Parameters:

NameTypeDescription
unValueBN | number | string-
decimalsnumber

Returns: string

isSafeInteger

â–¸ isSafeInteger(value: any): boolean

Defined in packages/util/src/is/integer.ts:30

Check if the input is a integer

example:

import { isInteger } from '@cennznet/util';

console.log('isInteger', isInteger(123)); // => true
console.log('isInteger', isInteger(123456789012345678)); // => false
console.log('isInteger', isInteger('123')); // => true
console.log('isInteger', isInteger('12.3')); // => false

Parameters:

NameType
valueany

Returns: boolean

parseUnits

â–¸ parseUnits(value: string | number, decimals: number): BN

Defined in packages/util/src/unit/parseUnits.ts:27

format a amount from unit un to decimals passed in.

Parameters:

NameTypeDescription
valuestring | number
decimalsnumber

Returns: BN

stripEndZero

â–¸ stripEndZero(value: string): string

Defined in packages/util/src/format/stripEndZero.ts:23

trim all trailing zeros. return '' if only zero is passed in.

Parameters:

NameTypeDescription
valuestring

Returns: string

toFixed

â–¸ toFixed(x: number): string

Defined in packages/util/src/number/toFixed.ts:19

convert number to string, without science notion

Parameters:

NameTypeDescription
xnumber

Returns: string

Keywords

CENNZNet

FAQs

Package last updated on 03 Mar 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts