@erfffun/utils

0.0.25 • Public • Published

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,
});

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
0.0.251latest

Version History

VersionDownloads (Last 7 Days)Published
0.0.251
0.0.240
0.0.230
0.0.220
0.0.210
0.0.200
0.0.190
0.0.180
0.0.170
0.0.160
0.0.150
0.0.140
0.0.130
0.0.120
0.0.110
0.0.100
0.0.90
0.0.80
0.0.70
0.0.60
0.0.50
0.0.40
0.0.30
0.0.20
0.0.10

Package Sidebar

Install

npm i @erfffun/utils

Weekly Downloads

1

Version

0.0.25

License

BSD-3-Clause

Unpacked Size

92.6 kB

Total Files

73

Last publish

Collaborators

  • erfffun