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 in either direction with lightweight precision.
The Problem

The Solution

Install
npm install satoshi-bitcoinUsage
var converter = require('satoshi-bitcoin');
console.log('One Bitcoin equals ' + converter.toSatoshi(1));
console.log('One Satoshi equals ' + converter.toBitcoin(1));Advanced Usage
var converter = require('satoshi-bitcoin');
//Try catch only needed if input may not be valid numbers
try {
console.log('One Bitcoin equals ' + converter.toSatoshi(1));
console.log('false Bitcoin equals ' + converter.toSatoshi(false)); //Throw 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 performingjsdox index.js --output wiki - Licensed under MIT
Tests
gruntRelease 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