numbro: Regression on null v1.9.3 to v1.10.0
I appears there has been a behavioural change between v1.9.3 and v.1.10.0 for the following code:
console.log(numbro(null).format("0.00%"));
1.9.3 fiddle
https://jsfiddle.net/deenairn/L6bygxdw/3/
This outputs: NaN%
1.10.0 fiddle
https://jsfiddle.net/deenairn/1nywjby3/2/
This throws:
Uncaught Error: Invalid input numbro.min.js:117
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 3
- Comments: 17 (9 by maintainers)
Commits related to this issue
- Do not throw error on invalid input Fix #265 — committed to gwynjudd/numbro by BenjaminVanRyseghem 7 years ago
- Do not throw error on invalid input Fix #265 — committed to gwynjudd/numbro by BenjaminVanRyseghem 7 years ago
- Do not throw error on invalid input Fix #265 — committed to gwynjudd/numbro by BenjaminVanRyseghem 7 years ago
I can remove it, it’s fine for me 😄
I think it may worth to make it configurable, like
numbro.config({ throwOnNan: true })
for cases, when developer want’s to be strict and ensure that numbro will never receive NaN.