🚀 Socket Launch Week 🚀 Day 4: Introducing Historical Analytics.Learn More
Socket
Sign inDemoInstall
Socket

currency-formatting

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

currency-formatting

Package to help you format numbers as currency and visa versa

0.0.2
latest
Source
npm
Version published
Weekly downloads
9
12.5%
Maintainers
1
Weekly downloads
 
Created
Source

currency-format

NPM

Coverage Status Build Status npm version Dependency Status devDependency Status

A small package that converts a number to currency format and visa versa.

Installation

Using cdn:

<script src="https://cdn.rawgit.com/tidupls/currency-format/master/dist/currency-format.min.js"></script>

Using npm:

$ npm install --save currency-formatting

Using bower:

$ bower install currency-formatting

Example

// Returns a formatted string.
// The number is formatted based on symbol, precision, decimal, thousand & format provided.
currency.format(5) // R 5.00
currency.format(500.555, '$') // $ 500.56
currency.format(4999.99, '€', 2, '.', ',') // € 4.999,99

// Returns a number for the string provided.
currency.unformat('$ 500,00', ',') // 500
currency.unformat('£ 12,345,678.90 GBP', '.'); // 12345678.9

API

Has two public methods:

  • format(number, symbol, precision, thousand, decimal, format)
  • unformat(value, decimal)

and a global settings object with defaults of:

var settings = {
    symbol: "$",		// default currency symbol
    format: "_s _v",    // format of currency _s = symbol & _v = value
    decimal: ".",		// decimal point separator
    thousand: ",",		// thousand separator
    precision: 2,		// decimal places
}

Tests

$ npm run test

Keywords

curreny

FAQs

Package last updated on 17 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