UNPKG

1.64 kBTypeScriptView Raw
1/// <reference types="bn.js" />
2import type { BN } from '../bn/bn';
3import type { SiDef, ToBn } from '../types';
4interface Defaults {
5 decimals: number;
6 unit: string;
7}
8interface SetDefaults {
9 decimals?: number[] | number;
10 unit?: string[] | string;
11}
12interface Options {
13 /**
14 * @description The number of decimals
15 */
16 decimals?: number;
17 /**
18 * @description Format the number with this specific unit
19 */
20 forceUnit?: string;
21 /**
22 * @description Format with SI, i.e. m/M/etc.
23 */
24 withSi?: boolean;
25 /**
26 * @description Format with full SI, i.e. mili/Mega/etc.
27 */
28 withSiFull?: boolean;
29 /**
30 * @description Add the unit (useful in Balance formats)
31 */
32 withUnit?: boolean | string;
33}
34interface BalanceFormatter {
35 <ExtToBn extends ToBn>(input?: number | string | BN | bigint | ExtToBn, options?: Options): string;
36 /** @deprecated Use balanceFormat(input?: number | string | BN | bigint | ExtToBn, options?: Options) */
37 <ExtToBn extends ToBn>(input?: number | string | BN | bigint | ExtToBn, options?: boolean, decimals?: number): string;
38 /** @deprecated Use balanceFormat(input?: number | string | BN | bigint | ExtToBn, options?: Options) */
39 <ExtToBn extends ToBn>(input?: number | string | BN | bigint | ExtToBn, options?: Options, decimals?: number): string;
40 calcSi(text: string, decimals?: number): SiDef;
41 findSi(type: string): SiDef;
42 getDefaults(): Defaults;
43 getOptions(decimals?: number): SiDef[];
44 setDefaults(defaults: SetDefaults): void;
45}
46export declare const formatBalance: BalanceFormatter;
47export {};