satoshi-rpgcoin

1.0.0 • Public • Published

satoshi-rpgcoin

npm module to convert between Satoshi and Rpgcoin with lightweight precision.



Install

npm install --save satoshi-rpgcoin

Usage

Node.js

var sb = require('satoshi-rpgcoin');

sb.toSatoshi(1);
//=>100000000

sb.toRpgcoin(100000000);
//=>1

Web

<script src="https://rawgit.com/RPGCoin/satoshi-rpgcoin/master/index.bundle.js"></script>
<script>
  console.log('One Satoshi equals ' + sb.toRpgcoin(1) + ' Rpgcoin');
</script>

Or download it with npm install --save satoshi-rpgcoin and reference it as:

<script src="node_modules/satoshi-rpgcoin/index.bundle.js"></script>

Error Handling

try {
  sb.toSatoshi(false)); //Throws TypeError
} catch (err) {
  console.log(err);
}

API

sb.toSatoshi(number || string)
sb.toRpgcoin(number || string)

Read more on the Wiki


FAQ

  • What is a Satoshi?

    • Satoshi is to Rpgcoin as pennies are to the dollar. Except that there are 100,000,000 Satoshi in one Rpgcoin.
  • Why do I need a module when I can just divide or multiply by 100,000,000?

    • See here - Floating point errors are a bitch. So satoshi-rpgcoin uses a bignum library to ensure accurate conversions!

Tests

npm test

License

MIT ©

Package Sidebar

Install

npm i satoshi-rpgcoin

Weekly Downloads

0

Version

1.0.0

License

MIT

Unpacked Size

37.2 kB

Total Files

5

Last publish

Collaborators

  • silence480