1 # extsprintf: extended POSIX-style sprintf
3 Stripped down version of s[n]printf(3c). We make a best effort to throw an
4 exception when given a format string we don't understand, rather than ignoring
5 it, so that we won't break existing programs if/when we go implement the rest
8 This implementation currently supports specifying
10 * field alignment ('-' flag),
12 * always show numeric sign ('+' flag),
14 * conversions for strings, decimal integers, and floats (numbers).
15 * argument size specifiers. These are all accepted but ignored, since
16 Javascript has no notion of the physical size of an argument.
18 Everything else is currently unsupported, most notably: precision, unsigned
19 numbers, non-decimal numbers, and characters.
21 Besides the usual POSIX conversions, this implementation supports:
23 * `%j`: pretty-print a JSON object (using node's "inspect")
24 * `%r`: pretty-print an Error object
30 # npm install extsprintf
34 var mod_extsprintf = require('extsprintf');
35 console.log(mod_extsprintf.sprintf('hello %25s', 'world'));