satoshi-bitcoin
npm module to convert between Satoshi and Bitcoin with lightweight precision.
The Problem
Install
npm install --save satoshi-bitcoin
yarn add satoshi-bitcoin
Usage
Node.js
var sb = require("satoshi-bitcoin");
sb.toSatoshi(1);
sb.toBitcoin(100000000);
Web
<script src="https://rawgit.com/dawsonbotsford/satoshi-bitcoin/master/index.bundle.js"></script>
<script>
console.log("One Satoshi equals " + sb.toBitcoin(1) + " Bitcoin");
</script>
Or download it with npm install --save satoshi-bitcoin
and reference it as:
<script src="node_modules/satoshi-bitcoin/index.bundle.js"></script>
Error Handling
try {
sb.toSatoshi(false);
} catch (err) {
console.log(err);
}
API
sb.toSatoshi(number || string)
sb.toBitcoin(number || string)
Read more on the Wiki
FAQ
Tests
npm test
License
MIT © Dawson Botsford