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 400,000 packages pre-installed, including usd with all npm packages installed. Try it out:

var usd = require("usd")

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

usd v1.0.3

AMD/CommonJS Stampit factory for creating models to handle USD logic

USD

AMD/CommonJS Stampit factory for creating models to handle USD logic

Install

npm install usd

Usage

var usd = require('usd');
var $price = usd().pennies(150);

console.log( $price.dollars() ); // => 1.50

Docs

Methods

.pennies() -> Number

Returns the value in pennies

.pennies( val ) -> this

Sets the value via pennies

.dollars() -> String

Returns the value in dollars

.dollars( val ) -> this

Sets the value via dollars

Static

.decimalAdjust( type, value, exp ) -> Number

Decimal adjustment of a number

Arguments

  • type - The type of adjustment
  • value - The value
  • exp - The exponent (the 10 logarithm of the adjustment base)

License

MIT

Metadata

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