
Product
Introducing Custom Pull Request Alert Comment Headers
Socket now lets you customize pull request alert headers, helping security teams share clear guidance right in PRs to speed reviews and reduce back-and-forth.
decimal-toformat
Advanced tools
Adds a toFormat
function to format decimal.js values.
Node.js
$ npm install decimal-toformat
const Decimal = require("decimal.js");
const { toFormat } = require("decimal-toformat");
x = new Decimal(9876.54321);
toFormat(x, 2) ; // '9,876.54'
// Set some format properties
toFormat(x, 1, {
decimalSeparator: ',',
groupSeparator: ' ',
groupSize: 2,
}); // '98 76,5'
let format = {
decimalSeparator: '.',
groupSeparator: ',',
groupSize: 3,
secondaryGroupSize: 0,
fractionGroupSeparator: '',
fractionGroupSize : 0
};
toFormat(x, format); // 123,456,789.987654321
toFormat(x, 2, 1, format); // 123,456,789.98
toFormat(x, {
decimalSeparator: ',',
groupSeparator: '',
}); // 123456789,987654321
format = {
decimalSeparator: '.',
groupSeparator: ' ',
groupSize: 3,
fractionGroupSeparator: ' ',
fractionGroupSize : 5
};
toFormat(x, format); // 123 456 789.98765 4321
toFormat(x, 4, format); // 123 456 789.9877
toFormat(x, 2, 1, format); // 123 456 789.98
$ npm test
FAQs
A `toFormat` function for decimal.js
We found that decimal-toformat 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 now lets you customize pull request alert headers, helping security teams share clear guidance right in PRs to speed reviews and reduce back-and-forth.
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.