
Security News
TypeScript is Porting Its Compiler to Go for 10x Faster Builds
TypeScript is porting its compiler to Go, delivering 10x faster builds, lower memory usage, and improved editor performance for a smoother developer experience.
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
The npm package number-formatter receives a total of 2,954 weekly downloads. As such, number-formatter popularity was classified as popular.
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
TypeScript is porting its compiler to Go, delivering 10x faster builds, lower memory usage, and improved editor performance for a smoother developer experience.
Research
Security News
The Socket Research Team has discovered six new malicious npm packages linked to North Korea’s Lazarus Group, designed to steal credentials and deploy backdoors.
Security News
Socket CEO Feross Aboukhadijeh discusses the open web, open source security, and how Socket tackles software supply chain attacks on The Pair Program podcast.