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.
js-number-formatter
Advanced tools
Readme
A javascript module that scans through string to remove non-numerals and formats out any found numbers based on configuration passed to it.
You need to have NodeJS installed on your computer before using npm
.
Open a terminal/command prompt and enter the codes below to install the package:
npm install js-number-formatter
// -- Require the module
import numberFormat from 'js-number-formatter';
const value = '3.142857';
const options = {
// ... check the parameters section for more info on options
};
// -- Call function and pass the value to format and options to it or just the value
numberFormat(value, options);
Parameter | Description |
value | The value to format which can be a number or string |
options |
|
numberFormat(3892); // Result: 3,892.00
numberFormat('140hajs7'); // Result: 1,407.00
numberFormat("you can't be serious ..."); // Result: 0
numberFormat("Hello World 20-06-2019", {
opAllowSign: false
}); // Result: 20,062,019.00
numberFormat('-00034dj^nkjlsd$knls4h%bj.34.5', {
// Returns zero '0' if string contains no digits
// default: true, [test: '-00034.dj^nkjls.d$knls.4h%bj345' | true: -34.4345 | false: -34.4345]
opReturnZeroIfNoDigit: true,
// Return the absolute number without possible preceeding zeros '0'
// default: true, [test: '-00034.dj^nkjls.d$knls.4h%bj345' | true: -34.4345 | false: -00,034.4345]
opReturnAbsoluteNumber: true,
// Allows sign (-) if true, removes any present sign if false
// default: true [test: '-00034.dj^nkjls.d$knls.4h%bj345' | true = -34.4345 | false = 34.4345]
opAllowSign: true,
// If decimal should be allowed or not
// default: true [test: '-00034.dj^nkjls.d$knls.4h%bj345' | true = -34.4345 | false = -34]
opAllowDecimal: true,
// Forces decimal even if string contains no decimal points (but only if opAllowDecimal is true)
// default: true [test: '-00034dj^nkjlsd$knls4h%bj345' | true: -344,345.00 | false: -344,345]
opForceDecimal: true,
// Ignores any already existing decimal point in the string (very useful for formatting number in input field)
// default: false
opIgnoreDecimal: true,
// Appends zero '0' to result if just one digit is found after the last decimal point
// default: true [test: '-00034dj^nkjlsd$knls4h%bj34.5' | true: -34,434.50 | false: -34,434.5]
opAppendZeroToDecimal: true,
// Character to use im place of the decimal period symbol
// default: '.'
opDecimalDelimiterChar: '.',
// Thousands separator
// default: ','
opDelimiterChar: ',',
// Thousands character spacing with ' '
// default: false [test: '-00034dj^nkjlsd$knls4h%bj.34.5' | true: -34, 434.50 | false: -34,434.50]
opAddSpaceToDelimiter: true
});
FAQs
A javascript module that scans through string to remove non-numerals and formats out any found numbers based on configuration passed to it.
The npm package js-number-formatter receives a total of 398 weekly downloads. As such, js-number-formatter popularity was classified as not popular.
We found that js-number-formatter demonstrated a healthy version release cadence and project activity because the last version was released less than 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.
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.