@cennznet/util
v1.5.3
Published
utils for CENNZnet api
Downloads
66
Readme
CENNZNet Util
Utils for CENNZNet
Functions
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:
| Name | Type | Description |
| ------ | ------ | ------ |
| unValue | BN
| number
| string
| - |
| decimals | number
| |
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:
| Name | Type |
| ------ | ------ |
| value | any
|
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:
| Name | Type | Description |
| ------ | ------ | ------ |
| value | string
| number
|
| decimals | number
| |
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:
| Name | Type | Description |
| ------ | ------ | ------ |
| value | string
| |
Returns: string
toFixed
▸ toFixed(x: number
): string
Defined in packages/util/src/number/toFixed.ts:19
convert number to string, without science notion
Parameters:
| Name | Type | Description |
| ------ | ------ | ------ |
| x | number
| |
Returns: string