Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
format-num
Advanced tools
Changelog
1.1.0 / 2024-02-08
refactored
improved unit tests
1.0.0 / 2016-03-17
Readme
format-num
is a JavaScript component to format numbers to strings. Used in Exodus Ethereum Wallet.
npm install --save format-num
Object.assign
and Intl.NumberFormat
.
In Node.js, this is at least v4. You can install in older environments, you'll just
need to polyfill.Signature: formatNum(value, [options])
Parameters:
value
: Value to convert. Will pass through parse-num first.
Will coerce anything to a number.options
: optional object
parameter to specify options.
Appending Digits
is not necessary. You can also shorten maximum
to max
and minimum
to min
. Adds one more option nanZero
, which when the number is
NaN
, if it should be coerced to 0
- defaults to true
i.e. NaN => '0'
.Returns:
The string
representation of the number.
Example:
const formatNum = require('format-num')
console.log(formatNum(10000000.15)) // => 10,000,000.15
console.log(formatNum('10000000.15')) // => 10,000,000.15
console.log(formatNum(0.0000000000044535, { maxSignificant: 2 })) // => 0.0000000000045
console.log(formatNum(0, { minFraction: 2, maxFraction: 2 })) // => 0.00
console.log(formatNum(null)) // => 0
console.log(formatNum(null, { nanZero: false })) // => NaN
MIT
FAQs
Format numbers.
The npm package format-num receives a total of 7,168 weekly downloads. As such, format-num popularity was classified as popular.
We found that format-num demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers 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
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.