JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 2498
  • Score
    100M100P100Q172823F
  • License MIT

Convert between Satoshi and Bitcoin with precision

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 Build Status npm version Code Climate

npm module to convert between Satoshi and Bitcoin in either direction with lightweight precision.

Imgur


## Install ```bash npm install satoshi-bitcoin ```
## Usage ```javascript var converter = require('satoshi-bitcoin'); console.log('One Bitcoin equals ' + converter.toSatoshi(1)); console.log('One Satoshi equals ' + converter.toBitcoin(1)); ```
### Advanced Usage ```javascript 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](https://github.com/dawsonbotsford/satoshi-bitcoin/blob/master/wiki/index.md)
## 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? * In the world of finance, floating point and unhandled type errors can cause catastrophic issues. ```satoshi-bitcoin``` handles that by implementing a bignum library in the background and descriptive error handling.
## Contributing Very open to pull requests.
  • After any change to index.js, update the Wiki by performing npm install -g jsdox && jsdox index.js --output wiki
  • Licensed under MIT

## Tests ```bash grunt ```
## Release History * 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

Donate Bitcoin