
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
comma-separator
Advanced tools
A package for separating numbers in hundreds, thousands, millions, billions and trillions and converts long numbers to readable strings
Separate numbers in hundreds, thousands, millions, billions and trillions and converts long numbers to readable strings.
$ npm install comma-separator
Nodejs Applications
const { addComma } = require("comma-separator");
Reactjs Applications
import { addComma } from "comma-separator";
const { addComma } = require("comma-separator");
addComma(5000000); // "5,000,000"
addComma(-10000); // "-10,000"
addComma(1000); // "1,000"
addComma(-1000); // "-1,000"
addComma(1000.12); // "1,000.12"
addComma(-1000.12); // "-1,000.12"
addComma("-200000000M"); // "-200,000,000M"
const { removeComma } = require("comma-separator");
removeComma("5,000,000"); // 5000000
removeComma("-10,000"); // -10000
removeComma("1,000"); // 1000
removeComma("-1,000"); // -1000
removeComma("-100,000,000 Millions"); // -100000000
const { strictAddComma } = require("comma-separator");
strictAddComma(5000000); // "5,000,000"
stritAddComma(-10000); // "10,000"
strictAddComma(-10000000); // "10,000,000"
strictAddComma("10000000M"); // "10,000,000"
strictAddComma("1000 thousand naira"); // "1,000"
strictAddComma("-200000000M"); // "200,000,000"
const { strictRemoveComma } = require("comma-separator");
strictRemoveComma("5,000,000"); // 5000000
strictRemoveComma("-10,000"); // 10000
strictRemoveComma("1,000"); // 1000
strictRemoveComma("-1,000"); // 1000
strictRemoveComma("1,000Thousand"); // 1000
strictRemoveComma("-100,000,000 Millions"); // 100000000
strictRemoveComma("-20.00,000,000Millions"); // 2000000000
const { convert } = require("comma-separator");
convert(5000); // 5K
convert(10000); //10K
convert(100000); //100K
convert(1000000); // 1M
convert(20000000); // 20M
convert(5000000000); // 5B
convert(100000000000); //100B
convert(5000000000000); // 5T
const { removeComma } = require("comma-separator");
const ex1 = "10,000";
const ex2 = "-3,000";
const ex3 = 1000;
const ex4 = "1,000 naira";
const calculateSum = (...rest) => {
let arr = [];
rest.forEach((item) => {
arr.push(removeComma(item));
});
return arr.reduce((acc, item) => {
return acc + item;
}, 0);
};
const response = calculateSum(ex1, ex2, ex3, ex4);
console.log(response);
`Result = 9000`;
const { removeComma } = require("comma-separator");
const ex1 = "10,000";
const ex2 = "3,000";
const ex3 = 1000;
const ex4 = "1,000 naira";
const calculateSum = (...rest) => {
let arr = [];
rest.forEach((item) => {
arr.push(removeComma(item));
});
return arr.reduce((acc, item) => {
return acc + item;
}, 0);
};
const response = calculateSum(ex1, ex2, ex3, ex4);
console.log(response);
`Result = 15000`;
const { strictRemoveComma } = require("comma-separator");
const ex1 = "10,000";
const ex2 = "-3,000";
const ex3 = 1000;
const ex4 = "1,000 naira";
const calculateSum = (...rest) => {
let arr = [];
rest.forEach((item) => {
arr.push(strictRemoveComma(item));
});
return arr.reduce((acc, item) => {
return acc + item;
}, 0);
};
const response = calculateSum(ex1, ex2, ex3, ex4);
console.log(response);
`Result = 15000`;
FAQs
A package for separating numbers in hundreds, thousands, millions, billions and trillions and converts long numbers to readable strings
The npm package comma-separator receives a total of 1 weekly downloads. As such, comma-separator popularity was classified as not popular.
We found that comma-separator 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.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.