Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
format-number
Advanced tools
Formats numbers with separators every 3 digits and currency etc. Highly configurable.
Highly configurable formatter that expects a valid number in 'computer' format and accepts the following as options for formatting
negativeType
string: 'right','left','brackets','none'; default = 'left' (note only used for setting of default symbols)negativeLeftSymbol
string: default = '-' if negativeType
is 'left', '(' if negativeType
is 'brackets' and '' otherwisenegativeRightSymbol
string: default = '-' if negativeType
is 'right', ')' if negativeType
is 'brackets' and '' otherwisenegativeLeftOut
boolean: whether the left symbol should be outside, ie precede the prefix; default = truenegativeRightOut
boolean: whether the right symbol should be outside, ie follow the suffix; default = trueprefix
string: default = ''suffix
string: default = ''integerSeparator
string: to be used as the thousands separator; default = ','decimalsSeparator
string: to be used as the thousanths separator; default = ''decimal
string: char to be used as decimal point; default = '.'padLeft
number: leading 0s will be added to left of number to make integer part this length; default = -1 /no paddingpadRight
number: trailing 0s will be added; default = -1 /no paddinground
number: number of decimal places to round to (rounds to nearest integer, mid point rounds away from zero ie 3.55 ~ 3.6 to 1dp, -3.55 ~ -3.6 to 1dp; default = no roundingtruncate
number: number of decimal places to truncate (3.58 truncates to 3.5 for 1dp, 3 for 0dp); default = no truncatingnoUnits
boolean: if true will override and leave out prefix and suffix; default= falsenoSeparator
- boolean: if true will override both integer and decimals separator and leave them outvar format=require('format-number');
var formattedNumber = format({prefix: '£', suffix: '/item'})(68932, {noSeparator: true});
or
var format=require('format-number');
var myFormat = format({prefix: '£', suffix: '/item'});
var formattedNumber = myFormat(68932, {noSeparator: true});
will both set formattedNumber to '£68932/item'
The override options can be ommitted:
var format=require('format-number');
var formattedNumber = format({prefix: '£', suffix: '/item'})(68932);
returns '£68,932/item'
FAQs
Formats numbers with separators every 3 digits and currency etc. Highly configurable.
The npm package format-number receives a total of 38,345 weekly downloads. As such, format-number popularity was classified as popular.
We found that format-number 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 malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.