Package Exports
- satoshi-bitcoin
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 (satoshi-bitcoin) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
satoshi-bitcoin
npm module to convert between Satoshi and Bitcoin with lightweight precision.
The Problem

Install
npm install --save satoshi-bitcoin
# OR
yarn add satoshi-bitcoinUsage
Node.js
var sb = require("satoshi-bitcoin");
sb.toSatoshi(1);
//=>100000000
sb.toBitcoin(100000000);
//=>1Web
<!-- package injected as "sb" -->
<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); //Throws TypeError
} catch (err) {
console.log(err);
}API
sb.toSatoshi(number || string)
sb.toBitcoin(number || string)
FAQ
What is a Satoshi?
- Satoshi is to Bitcoin as pennies are to the dollar. Except that there are 100,000,000 Satoshi in one Bitcoin.
Why do I need a module when I can just divide or multiply by 100,000,000?
- See here - Floating point errors are a problem. So
satoshi-bitcoinuses a tiny bignum library (big.js) to ensure accurate conversions!
- See here - Floating point errors are a problem. So
Tests
npm testLicense
MIT © Dawson Botsford