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 Satoshi <-> 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);
}Full API Reference
Fully generated jsdoc documentation on the Wiki
FAQ
- What is a Satoshi?
- Satoshi is currently the smallest possible 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: In the world of finance, floating point and unhandled type errors can cause catastrophic issues.
satoshi-bitcoinhandles that by implementing a bignum library in the background and descriptive error handling.
- See here - Explanation: In the world of finance, floating point and unhandled type errors can cause catastrophic issues.
Contributing
Open to pull requests.
- After any change to
index.js, update the Wiki by performingnpm run wiki - Licensed under MIT
Tests
npm testRelease History
- 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