accounting-js
Number, money and currency formatting library.

accounting-js downloads accounting-js version accounting-js license

accounting-js類似套件:
npm下載趨勢
3 年
🌟 在 accounting-js 的 README.md 中顯示即時使用量圖表,只需複製下面的代碼。
## Usage Trend
[![Usage Trend of accounting-js](https://npm-compare.com/img/npm-trend/THREE_YEARS/accounting-js.png)](https://npm-compare.com/accounting-js#timeRange=THREE_YEARS)
Cumulative GitHub Star Trend
🌟 在 accounting-js 的 README.md 中顯示 GitHub stars 趨勢圖表,只需複製下面的代碼。
## GitHub Stars Trend
[![GitHub Stars Trend of accounting-js](https://npm-compare.com/img/github-trend/accounting-js.png)](https://npm-compare.com/accounting-js)
統計詳情
套件
下載數
Stars
大小
Issues
發布時間
許可
accounting-js23,98411546.9 kB105 個月前MIT
accounting-js 的 README

NPM version

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.

Documentation

Quickstart

Install

npm install accounting-js

Use

Format number

import { formatNumber } from 'accounting-js';

// Default usage
formatNumber(5318008);
// ⇨ 5,318,008

// Custom format
formatNumber(9876543.21, { precision: 3, thousand: " " });
// ⇨ 9 876 543.210

Format money

import { formatMoney } from 'accounting-js';

// Default usage
formatMoney(12345678);
// ⇨ $12,345,678.00

// European formatting (custom symbol and separators)
formatMoney(4999.99, { symbol: "€", precision: 2, thousand: ".", decimal: "," });
// ⇨ €4.999,99

Convert money to numeric

import { unformat } from 'accounting-js';

unformat('£ 12,345,678.90 GBP');
// ⇨ 12345678.9

Accounting toFixed()

// Native toFixed has rounding issues
(0.615).toFixed(2);
// ⇨ '0.61'

// With accounting-js
toFixed(0.615, 2);
// ⇨ '0.62'

Copyright (c) 2016-present Stanislav Lesnikov, MIT License

Copyright (c) 2014 Open Exchange Rates, MIT License