alexei / sprintf.js

sprintf.js is a complete open source JavaScript sprintf implementation
BSD 3-Clause "New" or "Revised" License
2.11k stars 291 forks source link

%.f fails with unexpected placeholder #181

Open daurnimator opened 5 years ago

daurnimator commented 5 years ago

https://github.com/fengari-lua/fengari/issues/147

C language docs says the following about .precision field in sprintf() format:

If the period is specified without an explicit value for precision, 0 is assumed.

$ node
> require("sprintf-js").sprintf("%.f", 2)
Thrown:
SyntaxError: [sprintf] unexpected placeholder
> require("sprintf-js").sprintf("%.0f", 2)
'2'
ashwalk33r commented 4 years ago

PR with fix https://github.com/alexei/sprintf.js/pull/188