s.js

tiny javascript sprintf

Stars
20

s.js: minimalistic javascript sprintf().

// standalone
s('http://%s:%d', 'localhost', 40)
s('got %j', { this: 'will be JSON.stringified' })

// extend String.prototype
s.extend();
'http://%s:%d'.s('localhost', 40);
  • Node/browser compatible. Published as s on npm.
  • Opt-in String.prototype extension
  • Only supports %s and %d. Escape % as %%.