Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 1,000,000+ packages pre-installed, including usd-please with all npm packages installed. Try it out:

var usdPlease = require("usd-please")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

usd-please v1.0.5

It transforms integers/decimals into USD currency format.

CircleCI styled with prettier minified

usd-please

Its only job is to transform integers/decimals into USD currency format. The production compilation weighs in at approximately 900 bytes!

Installation:

npm i -S usd-please@latest


Usage:

usd(figureToBeFormatted: number, returnDollarsAndCents: boolean) => string | undefined


Example with cents:

const usd = require('usd-please')
const dollars = 1234.56
const formattedDollars = usd(dollars, true)

console.log(`${formattedDollars}`)
// =>  $1,234.56

Example without cents:

const usd = require('usd-please')
const dollars = 1234.56
const formattedDollars = usd(dollars)

console.log(`${formattedDollars}`)
// =>  $1,235
RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free