
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.
NodeJS simple number formatter.
npm i ziffer
const ziffer = require("ziffer");
const euro = ziffer({ inprefix: "€ ", decimals: 2 });
// prints "€ 12 345,68"
console.log(euro.format(12345.678));
// prints "-€ 12_345::7"
console.log(euro.format(-12345.678, { decimals: 1, thousands: "_", decimal: "::" }));
// prints "(€ 12 345,68)"
console.log(euro.format(-12345.678, { negative: "paren" }));
// prints -12345.678
console.log(euro.unformat("(€ 12 345,68)", { negative: "paren" }));
When creating a ziffer formatter you can pass any of these options in an optional object. These will be the defaults to subsequent .format() calls. You can also set an individual option in a specific call by passing a second options argument as seen above.
List of Options
decimal: separator between integer and fraction (default: comma)thousands: separator between integer groups (default: space)outprefix: string prefix (default: none)inprefix: string prefix (default: none)insuffix: string suffix (default: none)outsuffix: string suffix (default: none)negative: how negative values are expressed - "left", "right" or parenthesis (default: left)group: size of digit groups separated by thousands (default: 3)group_except: exception for digit grouping (default: 4)decimals: number of decimals in fraction to round to (default: no rounding)digits: a string with 10 digits from 0 to 9 (default: empty, which means 0-9)The reason there's an in and out prefix and suffix is because of how negative values are formatted. The negative characters (minus or parenthesis) are placed in between, which leaves you the opportunity to format any way you like.
Here's a weird example:
const ziffer = require("ziffer");
const euro = ziffer({
outprefix : "<",
inprefix : "[",
insuffix : "]",
outsuffix : ">",
negative : "paren"
});
// prints <([123])>
console.log(euro.format(-123));
// notice how parenthesis are place in between
Integer digit grouping can also be configured using a list of group sizes instead of a single number. This allows, for example, to group digits the way Hindi do.
const ziffer = require("ziffer");
const hindi = ziffer({
decimal : ".",
thousands : ",",
group : [ 3, 2 ],
decimals : 2
});
// prints 12,34,56,789.00
console.log(hindi.format(123456789));
For example, converting numbers to Arabic numeral can be done like the following:
const ziffer = require("ziffer");
const arab = ziffer({
digits : "٠١٢٣٤٥٦٧٨٩"
});
// prints ١٥٩
console.log(arab.format(159));
FAQs
NodeJS simple number formatter
The npm package ziffer receives a total of 11 weekly downloads. As such, ziffer popularity was classified as not popular.
We found that ziffer 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.