Security News
pnpm 10.0.0 Blocks Lifecycle Scripts by Default
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
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 3,367 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
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.
Research
Security News
Socket researchers have discovered multiple malicious npm packages targeting Solana private keys, abusing Gmail to exfiltrate the data and drain Solana wallets.