Package Exports
- ethereumjs-units
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (ethereumjs-units) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
ethereumjs-units
Unit conversion utility.
There are two methods:
convert(value, unitFrom, unitTo)
- convert a value between two unitslazyConvert(value, unitTo)
- include unit type in the input and the output
The value
and the output in all cases is a string.
Examples
Units.convert('1', 'eth', 'wei') // '1000000000000000000'
Units.convert('1', 'wei', 'eth') // '0.000000000000000001'
Units.convert('1', 'finney', 'eth') // '0.001'
Units.lazyConvert('1 eth', 'wei') // '1000000000000000000 wei'
Units.lazyConvert('1 wei', 'eth') // '0.000000000000000001 eth'
Units.lazyConvert('1 finney', 'eth') // '0.001 eth'
Units
Units are defined in units.json
. It is compatible with web3.js and additionally includes ETH
.