
Product
Rust Support Now in Beta
Socket's Rust support is moving to Beta: all users can scan Cargo projects and generate SBOMs, including Cargo.toml-only crates, with Rust-aware supply chain checks.
number-formatierer
Advanced tools
npm install --save number-formatierer
or
yarn add number-formatierer
var numberFormat = require('number-formatierer')
//import numberFormat from 'number-formatierer' ES6
numberFormat("-12.0000") // "-12"
numberFormat(120000) // "120,000"
numberFormat(-120000, 2) // "-120,000.00"
numberFormat(131277.092213, 2, 3) // "131,277.09"
numberFormat(131277.092213, 2, 3, "#") // "131#277.09"
numberFormat(131277.092213, 2, 3, "#","|") // "131#277|09"
Parameters:
Returns:
The numberFormat
function accepts these same parameters as the second and third params. This prevents using currying to bind them and reuse that bound function.
The bindWith
function accepts the options and returns a function bound with them.
var numberFormat = require('number-formatierer')
//import numberFormat from 'number-formatierer' ES6
const _bindWith = numberFormat.bindWith(2, 4, ",", ".")
_bindWith(131277.092213); // 13,1277.09
same as number.toFixed
and More accurate than number.toFixed
Parameters:
var numberFormat = require('number-formatierer')
//import numberFormat from 'number-formatierer' ES6
numberFormat.toFixed(0.015, 2); // 0.02
numberFormat.toFixed(0.025, 2); // 0.03
numberFormat.toFixed(0.035, 2); // 0.04
numberFormat.toFixed(0.045, 2); // 0.05
(0.015).toFixed(2); //0.01
(0.025).toFixed(2); //0.03
(0.035).toFixed(2); //0.04
(0.045).toFixed(2); //0.04
FAQs
Format a number with commas
We found that number-formatierer 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.
Product
Socket's Rust support is moving to Beta: all users can scan Cargo projects and generate SBOMs, including Cargo.toml-only crates, with Rust-aware supply chain checks.
Product
Socket Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.
Security News
Socket CEO Feross Aboukhadijeh joins Risky Business Weekly to unpack recent npm phishing attacks, their limited impact, and the risks if attackers get smarter.