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

The Solution

Install
npm install --save satoshi-bitcoinUsage
Node.js
var sb = require('satoshi-bitcoin');
console.log('One Bitcoin is ' + sb.toSatoshi(1) + ' Satoshi');
console.log('One Satoshi equals ' + sb.toBitcoin(1) + ' Bitcoin');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>
Error Handling
try {
sb.toSatoshi(false)); //Throws TypeError
} catch (err) {
console.log(err);
}API
toSatoshi(number)toBitcoin(number)
FAQ
What is a Satoshi?
- Satoshi is the smallest sub-unit of Bitcoin. 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 myself?
- See here - Explanation:
satoshi-bitcoinhandles floating point arithmetic errors by implementing a bignum library and descriptive error handling.
- See here - Explanation:
Contributing
Open to pull requests.
- After any change to
index.js, update the Wiki by performingnpm run wiki - After any change to
index.js, update the browser bundle by performingnpm run wiki - Licensed under MIT
Tests
npm testRelease History
- 0.3.5 Improve documentation
- 0.3.4 Add browserified pack for web usage
- 0.3.2 Compress total package size in half and minify
- 0.3.0 Support string input. Update README
- 0.2.0 Error handling Implemented. Switched to grunt.
- 0.1.2 Handle floating point corner cases and added lint tests
- 0.1.1 README updates to reference wiki
- 0.1.0 Initial release