Skip to content

Commit 22184ca

Browse files
committed
Update README.md
1 parent 14f790d commit 22184ca

File tree

1 file changed

+60
-17
lines changed

1 file changed

+60
-17
lines changed

README.md

Lines changed: 60 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,69 @@
1-
[![Build Status](https://travis-ci.org/nashdot/accounting-js.svg?branch=master)](https://travis-ci.org/nashdot/accounting-js)
21
[![NPM version](https://img.shields.io/npm/v/accounting-js.svg)](https://www.npmjs.com/package/accounting-js)
3-
[![Docs](http://nashdot.github.io/accounting-js/docs/badge.svg)](http://nashdot.github.io/accounting-js/docs)
42

53
**accounting-js** is a tiny JavaScript library for number, money and currency parsing/formatting. It's lightweight, fully localizable, has no dependencies, and works great client-side or server-side. Use standalone or as a nodeJS/npm and AMD/requireJS module.
64

7-
[Documentation](http://nashdot.github.io/accounting-js/docs)
5+
[Documentation](http://nashdot.github.io/accounting-js)
86

9-
Same as original [accounting.js](http://openexchangerates.github.io/accounting.js), but
7+
## Quickstart
108

11-
* Rewritten with es6, respecting common style
12-
* Using Rollup to produce UMD version
13-
* Tested with [Ava](https://github.com/sindresorhus/ava), Coverage with [Nyc](https://github.com/bcoe/nyc)
14-
* Applied corrections from
15-
* @Lakshmi-Sharma
16-
* @spidergears
17-
* @jvc
18-
* @latentflip
19-
* @stevenbristol
20-
* @samosad
21-
* @solinas
22-
* Published as [**accounting-js**](https://www.npmjs.com/package/accounting-js) on NPM
9+
### Install
2310

24-
Copyright (c) 2016 Nashdot, MIT License
11+
```shell
12+
npm install accounting-js
13+
```
14+
15+
### Use
16+
17+
#### Format number
18+
19+
```javascript
20+
import { formatNumber } from 'accounting-js';
21+
22+
// Default usage
23+
formatNumber(5318008);
24+
// ⇨ 5,318,008
25+
26+
// Custom format
27+
formatNumber(9876543.21, { precision: 3, thousand: " " });
28+
// ⇨ 9 876 543.210
29+
```
30+
31+
#### Format money
32+
33+
```javascript
34+
import { formatMoney } from 'accounting-js';
35+
36+
// Default usage
37+
formatMoney(12345678);
38+
// ⇨ $12,345,678.00
39+
40+
// European formatting (custom symbol and separators)
41+
formatMoney(4999.99, { symbol: "", precision: 2, thousand: ".", decimal: "," });
42+
// ⇨ €4.999,99
43+
```
44+
45+
#### Convert money to numeric
46+
47+
```javascript
48+
import { unformat } from 'accounting-js';
49+
50+
unformat('£ 12,345,678.90 GBP');
51+
// ⇨ 12345678.9
52+
```
53+
54+
#### Accounting toFixed()
55+
56+
```javascript
57+
// Native toFixed has rounding issues
58+
(0.615).toFixed(2);
59+
// ⇨ '0.61'
60+
61+
// With accounting-js
62+
toFixed(0.615, 2);
63+
// ⇨ '0.62'
64+
```
65+
66+
---
67+
Copyright (c) 2016-present Stanislav Lesnikov, MIT License
2568

2669
Copyright (c) 2014 Open Exchange Rates, MIT License

0 commit comments

Comments
 (0)