sprintf.js
sprintf.js copied to clipboard
print nothing on %n
POSIX C/C++ sprintf have a specifier "n" that prints nothing. This can be useful in some cases to suppress content.
Would you mind implementing %n to print nothing in sprint.js?
Thanks!
What are the use cases?
In my case I use CometVisu as home automation visualization. It uses sprint.js and allows formatting with it. For my custom visualization I sometimes want to suppress output and there is currently no way to do so.
In general I suppose the use case is exactly the same as %n in C
@ctr49 I kind of like this idea, see https://github.com/alexei/sprintf.js/pull/228
There's one thing I'm undecided about. %n in C doesn't accept any options, however I think it would be cool if it did e.g. %+'#10n would result in ########## (i.e. as opposed to an empty string). What do you think about this?
#228 looks great, thanks!
Regarding the option I can see the point where such a syntax may make sense, but I'm not sure if overloading "n" (having a specific meaning in original sprintf) is self-explanatory or if it deserves a dedicated (conflict-free) option.