Add support for custom number formatting
Added support for custom number formatting. This way one can override the default formatting to support localization. Since localization usually depends on the environment (e.g. using Angular) the actual localization can as well be externalized.
Should help with #124.
Like I said in the PR you linked, I wouldn't do it without Intl or something similar
Rolling your own Intl seems a bit of an overkill, but fair enough. I'll use my modification for the time being and keep an eye on the #124 issue.
But all in all, kudos for the lib, it's a great lib!
I only suggested we shouldn't improvise
Btw, my guess you're in need to format monetary values. If that's the case, may I suggest using a library that does just that? accounting.js looks good
My use case is actually formatting numbers (not monetary) in an Angular application where we are using different locales depending on user settings. And there it's as easy as just using $filter('number')(value). That is why I thought that sprintf-js could just offer a simple extensibility point and then it's up to lib users what they do with it.
Btw, are you using the sprintf filter in Angular? Just asking.
Re extensibility: I totally understand what you're saying. Though I'm not that happy with the implementation of this lib (made some bad decisions in my youth 😀), it pretty much does what it's supposed to do and so I'm satisfied. Also the npm stats are positive. However, about a month ago I started thinking that it might be the time to move on and surpass sprintf. I've been pondering with the idea of implementing a different formatter that's similar in style and concept to Python's new style string formatter where you have more control over the formatting of any type whether built in or not. I haven't got the chance to write a prototype though 🙁 I can't promise anything, but I do hope I'll do it. Having said that, I don't see sprintf getting any of that candy.
Yes, I'm using the sprintf filter, with the addition of the number formatting that I mentioned.
Idea about a shiny new lib is definitely interesting! But yeah, adding some extensive features to sprintf is probably not feasible, I totally understand that.
Just wondering where this has got to. I also have a need to format large numbers (not currency) and it would be handy to have this in sprintf