
Security News
require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
number-formatter
Advanced tools
Lightweight & Fast JavaScript Number Formatter
This standalone number formatter is intended to be short and fast. As they are the main factors for a high performance JavaScript app. Development release is as short as < 120 lines including license info, blank lines and comments. And production release is less than 1,200 bytes.
numberFormatter( "#,##0.####", 1234567.890 ); // output: "1,234,567.89"
numberFormatter( "$ #,###.00", -1234567.890 ); // output: "$ -1,234,567.89"
#,##0.00
or with negation -000.####
.# ##0,00
, #,###.##
, #'###.##
or any type of non-numbering symbol.#,##,#0.000
or #,###0.##
are all valid.##,###,##.#
or 0#,#00#.###0#
are all OK.numberFormatter( "0.0000", 3.141592)
.$#,##0.00
or #,###.##USD
will not yield expected outcome. Use '$'+numberFormatter('#,##0.00', 123.45)
or numberFormatter('#,##0.00', 456.789) + 'USD'
0-9
), dashes (-
), or plus signs (+
).$ npm install --save number-formatter
$ bower install --save number-formatter
When there's only one symbol is supplied, system will always treat the single symbol as Decimal. For instance, numberFormatter( '#,###', 1234567.890)
will output 1234567,890
. To force a single symbol as Separator, add a trailing dot to the end like this: numberFormatter( '#,###.', 1234567.890)
which will then output 1,234,567
.
A demo/sample page with few examples is provided (DEMO). The code is safe to be minimized using Google Compiler in Advanced mode.
FAQs
Lightweight & Fast JavaScript Number Formatter
We found that number-formatter 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
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
Security News
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.