Skip to content

Commit d15ef20

Browse files
estliberitasMyles Borins
authored andcommitted
doc: improvements to console.markdown copy
Fix missing links. Fix styling of printf() - once #5073 lands, link to man page will be auto-generated. Fix several typos. PR-URL: #5225 Reviewed-By: Roman Reiss <me@silverwind.io> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent 593206a commit d15ef20

File tree

1 file changed

+20
-17
lines changed

1 file changed

+20
-17
lines changed

doc/api/console.markdown

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ myConsole.warn(`Danger ${name}! Danger!`);
4848
```
4949

5050
While the API for the `Console` class is designed fundamentally around the
51-
Web browser `console` object, the `Console` is Node.js is *not* intended to
51+
Web browser `console` object, the `Console` in Node.js is *not* intended to
5252
duplicate the browsers functionality exactly.
5353

5454
## Asynchronous vs Synchronous Consoles
@@ -90,7 +90,7 @@ logger.log('count: %d', count);
9090
```
9191

9292
The global `console` is a special `Console` whose output is sent to
93-
`process.stdout` and `process.stderr`. It is equivalent to calling:
93+
[`process.stdout`][] and [`process.stderr`][]. It is equivalent to calling:
9494

9595
```js
9696
new Console(process.stdout, process.stderr);
@@ -99,7 +99,7 @@ new Console(process.stdout, process.stderr);
9999
### console.assert(value[, message][, ...])
100100

101101
A simple assertion test that verifies whether `value` is truthy. If it is not,
102-
an `AssertionError` is throw. If provided, the error `message` is formatted
102+
an `AssertionError` is thrown. If provided, the error `message` is formatted
103103
using [`util.format()`][] and used as the error message.
104104

105105
```js
@@ -111,27 +111,27 @@ console.assert(false, 'Whoops %s', 'didn\'t work');
111111

112112
### console.dir(obj[, options])
113113

114-
Uses [`util.inspect()`][] on `obj` and prints the resulting string to stdout.
114+
Uses [`util.inspect()`][] on `obj` and prints the resulting string to `stdout`.
115115
This function bypasses any custom `inspect()` function defined on `obj`. An
116-
optional `options` object may be passed that alters certain aspects of the
116+
optional `options` object may be passed to alter certain aspects of the
117117
formatted string:
118118

119119
- `showHidden` - if `true` then the object's non-enumerable and symbol
120120
properties will be shown too. Defaults to `false`.
121121

122-
- `depth` - tells `inspect` how many times to recurse while formatting the
123-
object. This is useful for inspecting large complicated objects. Defaults to
124-
`2`. To make it recurse indefinitely, pass `null`.
122+
- `depth` - tells [`util.inspect()`][] how many times to recurse while
123+
formatting the object. This is useful for inspecting large complicated objects.
124+
Defaults to `2`. To make it recurse indefinitely, pass `null`.
125125

126126
- `colors` - if `true`, then the output will be styled with ANSI color codes.
127127
Defaults to `false`. Colors are customizable; see
128128
[customizing `util.inspect()` colors][].
129129

130130
### console.error([data][, ...])
131131

132-
Prints to stderr with newline. Multiple arguments can be passed, with the first
133-
used as the primary message and all additional used as substitution
134-
values similar to `printf()` (the arguments are all passed to
132+
Prints to `stderr` with newline. Multiple arguments can be passed, with the
133+
first used as the primary message and all additional used as substitution
134+
values similar to `printf(3)` (the arguments are all passed to
135135
[`util.format()`][]).
136136

137137
```js
@@ -144,17 +144,17 @@ console.error('error', code);
144144

145145
If formatting elements (e.g. `%d`) are not found in the first string then
146146
[`util.inspect()`][] is called on each argument and the resulting string
147-
values are concatenated. See [`util.format()`][] for more information.
147+
values are concatenated. See [`util.format()`][] for more information.
148148

149149
### console.info([data][, ...])
150150

151151
The `console.info()` function is an alias for [`console.log()`][].
152152

153153
### console.log([data][, ...])
154154

155-
Prints to stdout with newline. Multiple arguments can be passed, with the first
156-
used as the primary message and all additional used as substitution
157-
values similar to `printf()` (the arguments are all passed to
155+
Prints to `stdout` with newline. Multiple arguments can be passed, with the
156+
first used as the primary message and all additional used as substitution
157+
values similar to `printf(3)` (the arguments are all passed to
158158
[`util.format()`][]).
159159

160160
```js
@@ -167,7 +167,7 @@ console.log('count: ', count);
167167

168168
If formatting elements (e.g. `%d`) are not found in the first string then
169169
[`util.inspect()`][] is called on each argument and the resulting string
170-
values are concatenated. See [`util.format()`][] for more information.
170+
values are concatenated. See [`util.format()`][] for more information.
171171

172172
### console.time(label)
173173

@@ -193,7 +193,7 @@ console.timeEnd('100-elements');
193193

194194
### console.trace(message[, ...])
195195

196-
Prints to stderr the string `'Trace :'`, followed by the [`util.format()`][]
196+
Prints to `stderr` the string `'Trace :'`, followed by the [`util.format()`][]
197197
formatted message and stack trace to the current position in the code.
198198

199199
```js
@@ -220,5 +220,8 @@ The `console.warn()` function is an alias for [`console.error()`][].
220220
[`console.log()`]: #console_console_log_data
221221
[`console.time()`]: #console_console_time_label
222222
[`console.timeEnd()`]: #console_console_timeend_label
223+
[`process.stderr`]: process.html#process_process_stderr
224+
[`process.stdout`]: process.html#process_process_stdout
223225
[`util.format()`]: util.html#util_util_format_format
224226
[`util.inspect()`]: util.html#util_util_inspect_object_options
227+
[customizing `util.inspect()` colors]: util.html#util_customizing_util_inspect_colors

0 commit comments

Comments
 (0)