console.log(numeral(-0.001).format('$0,0.00'));
// Outputs: 0$.00
According to me following code in library is causing the issue
if (value >= 0) {
symbols.before = symbols.before.replace(/[\-\(]/, '');
symbols.after = symbols.after.replace(/[\-\)]/, '');
} else if (value < 0 && (!numeral._.includes(symbols.before, '-') && !numeral._.includes(symbols.before, '('))) {
symbols.before = '-' + symbols.before;
}
Code should be changed to following
if (parseFloat(output) >= 0) {
symbols.before = symbols.before.replace(/[\-\(]/, '');
symbols.after = symbols.after.replace(/[\-\)]/, '');
} else if (parseFloat(output) < 0 && (!numeral._.includes(symbols.before, '-') && !numeral._.includes(symbols.before, '('))) {
symbols.before = '-' + symbols.before;
}
Clearly a bug and @vinaykharecha already provided the solution.
What are you guys waiting for?
Most helpful comment
Clearly a bug and @vinaykharecha already provided the solution.
What are you guys waiting for?