0.0.25 • Published 2 years ago
@erfffun/utils v0.0.25
energi-utils
Javascript utilities for web development
Available Methods:
amountToWei
Description: Convert number digit to wei Value
Usage
amountToWei(<amount as string>, <decimal>)
Example
amountToWei('1.01', 18);
copyToClipboard
Description: With this method, you can easily implement a copy to clip board feature
Usage
const result = copyToClipboard(<text>)
Response: Returns either a true/false depending on the status of the operation
Example
const result = copyToClipboard('Some text!');
if (result) {
console.log('Copied to clipboard');
} else {
throw new Error('Error: could not copy to clipboard');
}
detectMobile
Description: Detect if user is on a mobile device
Example
import { isMobile } from '@energi/utils';
if (isMobile) {
console.log('You are using a mobile device');
}
formatBN
Description: Module formats energi bignumber amounts (wei) into NRG amount, with decimal and thousands separator, internationalized
Usage
formatBN(toBN(bnStringRoundUp), {
locale,
decimals: 18, // force the format to have specific number of decimals
assetDigits: 18,
});
Example
import { formatBN } from '@energi/utils';
const locale = 'en-US';
formatBN(toBN(bnStringRoundUp), {
locale,
decimals: 2,
assetDigits: 18,
});
0.0.25
2 years ago
0.0.24
2 years ago
0.0.23
2 years ago
0.0.22
2 years ago
0.0.21
2 years ago
0.0.20
2 years ago
0.0.19
2 years ago
0.0.18
2 years ago
0.0.17
2 years ago
0.0.16
2 years ago
0.0.15
2 years ago
0.0.14
2 years ago
0.0.13
2 years ago
0.0.12
2 years ago
0.0.11
2 years ago
0.0.10
2 years ago
0.0.9
2 years ago
0.0.8
2 years ago
0.0.7
2 years ago
0.0.6
2 years ago
0.0.5
2 years ago
0.0.4
2 years ago
0.0.3
2 years ago
0.0.2
2 years ago
0.0.1
2 years ago