Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Browse files

Doc improvements

Fixes #1424.
  • Loading branch information...
1 parent 5501a5a commit 814f3ed303c3bc9890885e4190321a22ec976227 @koichik committed
Showing with 31 additions and 0 deletions.
  1. +31 −0 doc/api/util.markdown
31 doc/api/util.markdown
@@ -4,6 +4,37 @@ These functions are in the module `'util'`. Use `require('util')` to access
+### util.format()
+Returns a formatted string using the first argument as a `printf`-like format.
+The first argument is a string which may contain zero or more *placeholders*.
+Each placeholder is replaced with a converted value from corresponding
+argument. Placeholder can be:
+* `%s` - String.
+* `%d` - Number (both integer and float).
+* `%j` - JSON.
+* `%%` - single percent sign (`'%'`). This does not consume an argument.
+If the placeholder does not correspond to an available argument, then it is
+given an `undefined`.
+ util.format('%s:%s', 'foo'); // 'foo:undefined'
+If there are more arguments than placeholders, the extra arguments are
+converted to string by `util.inspect()` and these strings are concatenated,
+delimited by a space.
+ util.format('%s:%s', 'foo', 'bar', 'baz'); // 'foo:bar baz'
+If first argument is not a string then `util.format()` returns a string that
+concatenated all arguments in a space-delimited line. `util.inspect()` is used
+on each argument.
+ util.format(1, 2, 3); // '1 2 3'
### util.debug(string)
A synchronous output function. Will block the process and

0 comments on commit 814f3ed

Please sign in to comment.
Something went wrong with that request. Please try again.