
Research
/Security News
Critical Vulnerability in NestJS Devtools: Localhost RCE via Sandbox Escape
A flawed sandbox in @nestjs/devtools-integration lets attackers run code on your machine via CSRF, leading to full Remote Code Execution (RCE).
number-format.js
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.
format( "#,##0.####", 1234567.890 ); // output: "1,234,567.89"
format( "$ #,###.00", -1234567.890 ); // output: "$ 1,234,567.89"
// Added in v2.0.0
format( "$ #,###.00", -1234567.890, {ignoreMaskSign: true}); // output: "$ 1,234,567.89"
format( "$ -#,###.00", -1234567.890, {ignoreMaskSign: true}); // output: "$ -1,234,567.89"
format( "$ +#,###.00", -1234567.890, {ignoreMaskSign: true}); // output: "$ -1,234,567.89"
format( "$ +#,###.00", 1234567.890, {ignoreMaskSign: true}); // output: "$ +1,234,567.89"
† Initial development release of this code was written by KPL and hosted at Google Code.
#,##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.format( "0.0000", 3.141592)
.$#,##0.00
or #,###.##USD
will not yield expected outcome. Use '$'+format('#,##0.00', 123.45)
or format('#,##0.00', 456.789) + 'USD'
0-9
), dashes (-
), or plus signs (+
).npm install --save number-format.js
When only one symbol is supplied, the library will always treat that symbol as a decimal. For example, format( '#,###', 1234567.890)
will output 1234567,890
.
To force a single symbol to be used as a separator, add a trailing symbol. In this example, a period is added to the end of the mask - format( '#,###.', 1234567.890)
- resulting in it being used as a decimal and forcing the first symbol to be the separator and return this output: 1,234,567
.
A demo/sample page with few examples is provided (demo).
And a jsFiddle was created to aid in testing: https://jsfiddle.net/Mottie/t2etyodx/
View the complete change log here.
ignoreSign
option (modified to enforeceMaskSign
!).ignoreSign
to enforceMaskSign
(default false
).package.json
entry.bower.json
"main" reference.package.json
license format.FAQs
Lightweight & Fast JavaScript Number Formatter
The npm package number-format.js receives a total of 29,420 weekly downloads. As such, number-format.js popularity was classified as popular.
We found that number-format.js 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.
Research
/Security News
A flawed sandbox in @nestjs/devtools-integration lets attackers run code on your machine via CSRF, leading to full Remote Code Execution (RCE).
Product
Customize license detection with Socket’s new license overlays: gain control, reduce noise, and handle edge cases with precision.
Product
Socket now supports Rust and Cargo, offering package search for all users and experimental SBOM generation for enterprise projects.