🚀 DAY 5 OF LAUNCH WEEK:Introducing Webhook Events for Alert Changes.Learn more →
Socket
Book a DemoInstallSign in
Socket

money_beans

Package Overview
Dependencies
Maintainers
2
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

money_beans

Create JS money objects from strings, integers or floats

latest
Source
npmnpm
Version
1.0.3
Version published
Maintainers
2
Created
Source

Money

Create JS money objects from strings, integers or floats

Get started

Money = require('money')

new Money()
# returns => Object {cents: 0}

new Money('12.2')
# returns => Object {cents: 1220}

new Money(195)
# returns => Object {cents: 19500}

Render

Money = require('money')
price = new Money(10)

price.format()
# returns = '10.00'

price.render()
# returns => "<span class='money positive'>$10.00</span>"

Operations

Money = require('money')

## Multiply

productPrice = new Money('49.95')
quantity = 3
subTotal = productPrice.multiply(quantity)
# returns => Object {cents: 14985}

## Addition

shipping = new Money('20')
total = subTotal.add(shipping)
# returns => Object {cents: 16985}

## Subtraction

discount = new Money('10')
finalTotal = total.subtract(discount)
# returns => Object {cents: 15985}

Keywords

money

FAQs

Package last updated on 07 Jul 2016

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