Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

xrb-prettify

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

xrb-prettify

Format RaiBlocks raw amounts (xrb) to be more human-readable. Adds decimal point and commas where necessary.

  • 1.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

xrb-prettify

Format RaiBlocks raw amounts (xrb) to be more human-readable. Adds decimal point and commas where necessary.

e.g. 1002513383 becomes 1,002.513383

Install

npm install --save xrb-prettify

Include in scripts

// require
var xrbPrettify = require('xrb-prettify').xrbPrettify

// require (ES6 version)
const { xrbPrettify } = require('xrb-prettify')

// import
import xrbPrettify from 'xrbPrettify'

Usage Example

xrbPrettify(1002513383)
// "1,002.513383"

API

xrbPrettify(xrbValue, config <optional>)

Parameters

xrbValue (number) - The raw XRB amount, usually returned when performing API calls to a RaiBlocks node.

config (object) <optional> - Configuration for the returned result. The configurations are:

  • commas (boolean) - Choose whether or not to display commas where necessary e.g. 1,000,000.000000. Default: true
  • decimals (boolean) - Choose whether or not to display decimal places. Default: true
Examples

Prettify an XRB amount

xrbPrettify(1002513383)
// Result: "1,002.513383"
// returns a string

Prettify an XRB amount without commas

xrbPrettify(1002513383, { commas: false })
// Result: 1002.513383
// returns a number

Prettify an XRB amount without decimal places

xrbPrettify(1002513383, { decimals: false })
// Result: "1,002"

Tests

/* run this command inside xrb-prettify's
   node_modules folder */

npm run test

Feedback

Pull requests and opened issues are welcome!

License

MIT

Keywords

FAQs

Package last updated on 18 Dec 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc