* Split ui-api, update API version * Update (awaiting API changes to go through) * Cleanup ui-api exports * Bump API (SubscriptionPromise support) * Linting fixes * Update renames * Do display balances.Transfer (shows for non-owned accounts) * Bump API
22 lines
608 B
TypeScript
22 lines
608 B
TypeScript
// Copyright 2017-2019 @polkadot/ui-api authors & contributors
|
|
// This software may be modified and distributed under the terms
|
|
// of the Apache-2.0 license. See the LICENSE file for details.
|
|
|
|
import BN from 'bn.js';
|
|
import { Compact } from '@polkadot/types/codec';
|
|
import { bnToBn } from '@polkadot/util';
|
|
|
|
import decimalFormat from './decimalFormat';
|
|
|
|
export default function numberFormat (_value?: Compact | BN | number | null): string {
|
|
if (!_value) {
|
|
return '0';
|
|
}
|
|
|
|
const value = _value instanceof Compact
|
|
? _value.toBn()
|
|
: bnToBn(_value);
|
|
|
|
return decimalFormat(value.toString());
|
|
}
|