summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/api/child_process.md10
-rw-r--r--doc/api/console.md3
-rw-r--r--doc/api/fs.md10
-rw-r--r--doc/api/modules.md3
-rw-r--r--doc/api/process.md4
-rw-r--r--doc/api/tls.md2
-rw-r--r--doc/api/zlib.md4
-rw-r--r--doc/guides/using-internal-errors.md2
-rw-r--r--doc/guides/writing-tests.md42
9 files changed, 44 insertions, 36 deletions
diff --git a/doc/api/child_process.md b/doc/api/child_process.md
index 816b37b250..d004147c77 100644
--- a/doc/api/child_process.md
+++ b/doc/api/child_process.md
@@ -101,7 +101,9 @@ bat.stderr.on('data', (data) => {
bat.on('exit', (code) => {
console.log(`Child exited with code ${code}`);
});
+```
+```js
// OR...
const exec = require('child_process').exec;
exec('my.bat', (err, stdout, stderr) => {
@@ -195,14 +197,14 @@ The `options` argument may be passed as the second argument to customize how
the process is spawned. The default options are:
```js
-{
+const defaults = {
encoding: 'utf8',
timeout: 0,
maxBuffer: 200*1024,
killSignal: 'SIGTERM',
cwd: null,
env: null
-}
+};
```
If `timeout` is greater than `0`, the parent will send the signal
@@ -362,10 +364,10 @@ trigger arbitrary command execution.**
A third argument may be used to specify additional options, with these defaults:
```js
-{
+const defaults = {
cwd: undefined,
env: process.env
-}
+};
```
Use `cwd` to specify the working directory from which the process is spawned.
diff --git a/doc/api/console.md b/doc/api/console.md
index 25726d0a82..a368e17913 100644
--- a/doc/api/console.md
+++ b/doc/api/console.md
@@ -69,6 +69,9 @@ or `console.Console`:
```js
const Console = require('console').Console;
+```
+
+```js
const Console = console.Console;
```
diff --git a/doc/api/fs.md b/doc/api/fs.md
index f3828f15e7..e41b135b6e 100644
--- a/doc/api/fs.md
+++ b/doc/api/fs.md
@@ -217,7 +217,7 @@ synchronous counterparts are of this type.
For a regular file [`util.inspect(stats)`][] would return a string very
similar to this:
-```js
+```txt
Stats {
dev: 2114,
ino: 48064969,
@@ -630,13 +630,13 @@ default value of 64 kb for the same parameter.
`options` is an object or string with the following defaults:
```js
-{
+const defaults = {
flags: 'r',
encoding: null,
fd: null,
mode: 0o666,
autoClose: true
-}
+};
```
`options` can include `start` and `end` values to read a range of bytes from
@@ -696,13 +696,13 @@ Returns a new [`WriteStream`][] object. (See [Writable Stream][]).
`options` is an object or string with the following defaults:
```js
-{
+const defaults = {
flags: 'w',
defaultEncoding: 'utf8',
fd: null,
mode: 0o666,
autoClose: true
-}
+};
```
`options` may also include a `start` option to allow writing data at
diff --git a/doc/api/modules.md b/doc/api/modules.md
index 65f57314cc..d40f25d0a9 100644
--- a/doc/api/modules.md
+++ b/doc/api/modules.md
@@ -558,7 +558,8 @@ object, it is common to also reassign `exports`, for example:
```js
module.exports = exports = function Constructor() {
- // ... etc.
+ // ... etc.
+};
```
To illustrate the behavior, imagine this hypothetical implementation of
diff --git a/doc/api/process.md b/doc/api/process.md
index 30e46d3541..0e8b46d403 100644
--- a/doc/api/process.md
+++ b/doc/api/process.md
@@ -529,7 +529,7 @@ running the `./configure` script.
An example of the possible output looks like:
-```js
+```txt
{
target_defaults:
{ cflags: [],
@@ -1708,7 +1708,7 @@ to load modules that were compiled against a different module ABI version.
console.log(process.versions);
```
-Will generate output similar to:
+Will generate an object similar to:
```js
{
diff --git a/doc/api/tls.md b/doc/api/tls.md
index 1e8bff1d49..a11631b013 100644
--- a/doc/api/tls.md
+++ b/doc/api/tls.md
@@ -1246,7 +1246,7 @@ stream.
`tls.TLSSocket()`. For example, the code:
```js
-pair = tls.createSecurePair( ... );
+pair = tls.createSecurePair(/* ... */);
pair.encrypted.pipe(socket);
socket.pipe(pair.encrypted);
```
diff --git a/doc/api/zlib.md b/doc/api/zlib.md
index a91456bb0b..804324521a 100644
--- a/doc/api/zlib.md
+++ b/doc/api/zlib.md
@@ -84,7 +84,9 @@ request.on('response', (response) => {
break;
}
});
+```
+```js
// server example
// Running a gzip operation on every request is quite expensive.
// It would be much more efficient to cache the compressed buffer.
@@ -159,7 +161,7 @@ For example, to reduce the default memory requirements from 256K to 128K, the
options should be set to:
```js
-{ windowBits: 14, memLevel: 7 }
+const options = { windowBits: 14, memLevel: 7 };
```
This will, however, generally degrade compression.
diff --git a/doc/guides/using-internal-errors.md b/doc/guides/using-internal-errors.md
index 9f8634dc23..948a87612e 100644
--- a/doc/guides/using-internal-errors.md
+++ b/doc/guides/using-internal-errors.md
@@ -52,7 +52,7 @@ and appending the new error codes to the end using the utility `E()` method.
```js
E('EXAMPLE_KEY1', 'This is the error value');
-E('EXAMPLE_KEY2', (a, b) => return `${a} ${b}`);
+E('EXAMPLE_KEY2', (a, b) => `${a} ${b}`);
```
The first argument passed to `E()` is the static identifier. The second
diff --git a/doc/guides/writing-tests.md b/doc/guides/writing-tests.md
index d0a6e1a199..70690e2fda 100644
--- a/doc/guides/writing-tests.md
+++ b/doc/guides/writing-tests.md
@@ -23,27 +23,27 @@ Add tests when:
Let's analyze this basic test from the Node.js test suite:
```javascript
-1 'use strict';
-2 const common = require('../common');
-3
-4 // This test ensures that the http-parser can handle UTF-8 characters
-5 // in the http header.
-6
-7 const assert = require('assert');
-8 const http = require('http');
-9
-10 const server = http.createServer(common.mustCall((req, res) => {
-11 res.end('ok');
-12 }));
-13 server.listen(0, () => {
-14 http.get({
-15 port: server.address().port,
-16 headers: {'Test': 'Düsseldorf'}
-17 }, common.mustCall((res) => {
-18 assert.strictEqual(res.statusCode, 200);
-19 server.close();
-20 }));
-21 });
+'use strict'; // 1
+const common = require('../common'); // 2
+ // 3
+// This test ensures that the http-parser can handle UTF-8 characters // 4
+// in the http header. // 5
+ // 6
+const assert = require('assert'); // 7
+const http = require('http'); // 8
+ // 9
+const server = http.createServer(common.mustCall((req, res) => { // 10
+ res.end('ok'); // 11
+})); // 12
+server.listen(0, () => { // 13
+ http.get({ // 14
+ port: server.address().port, // 15
+ headers: {'Test': 'Düsseldorf'} // 16
+ }, common.mustCall((res) => { // 17
+ assert.strictEqual(res.statusCode, 200); // 18
+ server.close(); // 19
+ })); // 20
+}); // 21
```
### **Lines 1-2**