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

add printf()? #109

Open Zorgatone opened 8 years ago

Zorgatone commented 8 years ago

Maybe we could have a printf(...) which would be a wrapper to console.log(sprintf(...)), what do you guys think?

spelunk commented 7 years ago

@Zorgatone it's literally one line to replicate the C printf behavior including the return value:

var printf = function() { var o = sprintf.apply(sprintf, arguments); console.log(o); return o.length; };
printf("Hello %s!", "World"); // prints 'Hello World!' to console, returns 12