Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
The accounting npm package is a lightweight JavaScript library for number, money, and currency formatting. It provides simple and easy-to-use methods for formatting numbers, currencies, and handling various financial calculations.
Number Formatting
This feature allows you to format numbers with thousand separators and decimal points. The formatNumber method takes a number and returns it as a string formatted with commas as thousand separators.
const accounting = require('accounting');
const formattedNumber = accounting.formatNumber(1234567.89);
console.log(formattedNumber); // '1,234,567.89'
Currency Formatting
This feature allows you to format numbers as currency. The formatMoney method takes a number and returns it as a string formatted as currency, including the currency symbol and proper decimal places.
const accounting = require('accounting');
const formattedCurrency = accounting.formatMoney(1234567.89);
console.log(formattedCurrency); // '$1,234,567.89'
Unformatting Numbers
This feature allows you to convert formatted numbers or currency strings back into plain numbers. The unformat method takes a formatted string and returns it as a number.
const accounting = require('accounting');
const number = accounting.unformat('$1,234,567.89');
console.log(number); // 1234567.89
Numeral.js is a library for formatting and manipulating numbers. It provides similar functionality to accounting, such as number formatting, currency formatting, and unformatting. However, Numeral.js offers more customization options and supports a wider range of number formats.
Currency.js is a library specifically designed for handling currency values. It provides methods for formatting, parsing, and manipulating currency values. Compared to accounting, currency.js offers more robust handling of currency-specific operations and better precision for financial calculations.
Dinero.js is a library for creating, calculating, and formatting monetary values in JavaScript. It provides a comprehensive set of tools for handling money, including arithmetic operations, formatting, and currency conversion. Dinero.js is more feature-rich compared to accounting and is designed to handle complex financial scenarios.
accounting.js is a tiny JavaScript library for number, money and currency parsing/formatting. It's lightweight, fully localisable, has no dependencies, and works great client-side or server-side. Use standalone or as a nodeJS/npm and AMD/requireJS module.
Visit the plugin homepage for demos and documentation: http://openexchangerates.github.io/accounting.js/
Please checkout or download the latest stable tag before using in production. Bug reports and pull requests are welcome.
Maintained by Open Exchange Rates and originally by @josscrowcroft and other contributors.
v0.4.1 - Alias accounting.formatNumber()
as accounting.format()
v0.4 - Transferred repository to Open Exchange Rates for ongoing maintenance
v0.3.2 - Fixed package.json dependencies (should be empty object)
v0.3.0
npm install accounting
and then var accounting = require("accounting");
in your nodeJS scripts.acounting.unformat
now also aliased as acounting.parse
defaults
methodv0.2.2 - Fixed same issue as #Num: #24 in formatNumber; switch to Google Closure Compiler for minified version.
v0.2.1 - Fixed issue #Num: #24 (locally-defined settings object was being modified by formatMoney)
v0.2
accounting.settings.currency.format
v0.1.4
v0.1.3
format
parameter to control symbol and value position (default "%s%v"
, or [symbol][value])v0.1.2
accounting.formatColumn( [[1,12,123,1234], [1234,123,12,1]] )
, returns matching array with inner columns lined up)v0.1.1
accounting.toFixed(value, precision)
), which treats floats more like decimals for more accurate currency roundingNaN
errors when no value in unformatv0.1 - First version
FAQs
number, money and currency formatting library
The npm package accounting receives a total of 199,185 weekly downloads. As such, accounting popularity was classified as popular.
We found that accounting demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.