Skip to content

Commit

Permalink
doc: remove redundant 'Example:' and similar notes
Browse files Browse the repository at this point in the history
Some nits were also fixed in passing.

PR-URL: #22537
Reviewed-By: Trivikram Kamat <[email protected]>
Reviewed-By: Ruben Bridgewater <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Sakthipriyan Vairamani <[email protected]>
Reviewed-By: James M Snell <[email protected]>
  • Loading branch information
vsemozhetbyt committed Aug 29, 2018
1 parent b2f0cfa commit 1a25f96
Show file tree
Hide file tree
Showing 27 changed files with 53 additions and 260 deletions.
2 changes: 1 addition & 1 deletion doc/api/assert.md
Original file line number Diff line number Diff line change
Expand Up @@ -675,7 +675,7 @@ changes:
Throws `value` if `value` is not `undefined` or `null`. This is useful when
testing the `error` argument in callbacks. The stack trace contains all frames
from the error passed to `ifError()` including the potential new frames for
`ifError()` itself. See below for an example.
`ifError()` itself.

```js
const assert = require('assert').strict;
Expand Down
4 changes: 1 addition & 3 deletions doc/api/async_hooks.md
Original file line number Diff line number Diff line change
Expand Up @@ -534,8 +534,6 @@ expensive nature of the [promise introspection API][PromiseHooks] provided by
V8. This means that programs using promises or `async`/`await` will not get
correct execution and trigger ids for promise callback contexts by default.

Here's an example:

```js
const ah = require('async_hooks');
Promise.resolve(1729).then(() => {
Expand All @@ -551,7 +549,7 @@ the `triggerAsyncId` value is `0`, which means that we are missing context about
the resource that caused (triggered) the `then()` callback to be executed.

Installing async hooks via `async_hooks.createHook` enables promise execution
tracking. Example:
tracking:

```js
const ah = require('async_hooks');
Expand Down
7 changes: 1 addition & 6 deletions doc/api/child_process.md
Original file line number Diff line number Diff line change
Expand Up @@ -642,8 +642,6 @@ pipes between the parent and child. The value is one of the following:
words, stdin, stdout, and stderr) a pipe is created. For fd 3 and up, the
default is `'ignore'`.

Example:

```js
const { spawn } = require('child_process');

Expand Down Expand Up @@ -1060,8 +1058,7 @@ See kill(2) for reference.

Also note: on Linux, child processes of child processes will not be terminated
when attempting to kill their parent. This is likely to happen when running a
new process in a shell or with use of the `shell` option of `ChildProcess`, such
as in this example:
new process in a shell or with use of the `shell` option of `ChildProcess`:

```js
'use strict';
Expand Down Expand Up @@ -1105,8 +1102,6 @@ added: v0.1.90

Returns the process identifier (PID) of the child process.

Example:

```js
const { spawn } = require('child_process');
const grep = spawn('grep', ['ssh']);
Expand Down
2 changes: 0 additions & 2 deletions doc/api/cluster.md
Original file line number Diff line number Diff line change
Expand Up @@ -765,8 +765,6 @@ Note that:
* The defaults above apply to the first call only, the defaults for later
calls is the current value at the time of `cluster.setupMaster()` is called.

Example:

```js
const cluster = require('cluster');
cluster.setupMaster({
Expand Down
12 changes: 1 addition & 11 deletions doc/api/crypto.md
Original file line number Diff line number Diff line change
Expand Up @@ -1678,8 +1678,6 @@ added: v0.9.3
* Returns: {string[]} An array with the names of the supported cipher
algorithms.

Example:

```js
const ciphers = crypto.getCiphers();
console.log(ciphers); // ['aes-128-cbc', 'aes-128-ccm', ...]
Expand All @@ -1691,8 +1689,6 @@ added: v2.3.0
-->
* Returns: {string[]} An array with the names of the supported elliptic curves.

Example:

```js
const curves = crypto.getCurves();
console.log(curves); // ['Oakley-EC2N-3', 'Oakley-EC2N-4', ...]
Expand All @@ -1711,7 +1707,7 @@ supported groups are: `'modp1'`, `'modp2'`, `'modp5'` (defined in
`'modp16'`, `'modp17'`, `'modp18'` (defined in [RFC 3526][]). The
returned object mimics the interface of objects created by
[`crypto.createDiffieHellman()`][], but will not allow changing
the keys (with [`diffieHellman.setPublicKey()`][] for example). The
the keys (with [`diffieHellman.setPublicKey()`][], for example). The
advantage of using this method is that the parties do not have to
generate nor exchange a group modulus beforehand, saving both processor
and communication time.
Expand Down Expand Up @@ -1747,8 +1743,6 @@ added: v0.9.3
* Returns: {string[]} An array of the names of the supported hash algorithms,
such as `'RSA-SHA256'`.

Example:

```js
const hashes = crypto.getHashes();
console.log(hashes); // ['DSA', 'DSA-SHA', 'DSA-SHA1', ...]
Expand Down Expand Up @@ -1797,8 +1791,6 @@ but will take a longer amount of time to complete.
The `salt` should be as unique as possible. It is recommended that a salt is
random and at least 16 bytes long. See [NIST SP 800-132][] for details.

Example:

```js
const crypto = require('crypto');
crypto.pbkdf2('secret', 'salt', 100000, 64, 'sha512', (err, derivedKey) => {
Expand Down Expand Up @@ -1862,8 +1854,6 @@ but will take a longer amount of time to complete.
The `salt` should be as unique as possible. It is recommended that a salt is
random and at least 16 bytes long. See [NIST SP 800-132][] for details.

Example:

```js
const crypto = require('crypto');
const key = crypto.pbkdf2Sync('secret', 'salt', 100000, 64, 'sha512');
Expand Down
7 changes: 3 additions & 4 deletions doc/api/dgram.md
Original file line number Diff line number Diff line change
Expand Up @@ -552,17 +552,16 @@ chained.
### Change to asynchronous `socket.bind()` behavior

As of Node.js v0.10, [`dgram.Socket#bind()`][] changed to an asynchronous
execution model. Legacy code that assumes synchronous behavior, as in the
following example:
execution model. Legacy code would use synchronous behavior:

```js
const s = dgram.createSocket('udp4');
s.bind(1234);
s.addMembership('224.0.0.114');
```

Must be changed to pass a callback function to the [`dgram.Socket#bind()`][]
function:
Such legacy code would need to be changed to pass a callback function to the
[`dgram.Socket#bind()`][] function:

```js
const s = dgram.createSocket('udp4');
Expand Down
6 changes: 0 additions & 6 deletions doc/api/domain.md
Original file line number Diff line number Diff line change
Expand Up @@ -311,8 +311,6 @@ The returned function will be a wrapper around the supplied callback
function. When the returned function is called, any errors that are
thrown will be routed to the domain's `'error'` event.

#### Example

```js
const d = domain.create();

Expand Down Expand Up @@ -370,8 +368,6 @@ objects sent as the first argument to the function.
In this way, the common `if (err) return callback(err);` pattern can be replaced
with a single error handler in a single place.

#### Example

```js
const d = domain.create();

Expand Down Expand Up @@ -415,8 +411,6 @@ the function.

This is the most basic way to use a domain.

Example:

```js
const domain = require('domain');
const fs = require('fs');
Expand Down
6 changes: 1 addition & 5 deletions doc/api/errors.md
Original file line number Diff line number Diff line change
Expand Up @@ -1243,8 +1243,7 @@ type for one of its returned object properties on execution.
### ERR_INVALID_RETURN_VALUE

Thrown in case a function option does not return an expected value
type on execution.
For example when a function is expected to return a promise.
type on execution, such as when a function is expected to return a promise.

<a id="ERR_INVALID_SYNC_FORK_INPUT"></a>
### ERR_INVALID_SYNC_FORK_INPUT
Expand All @@ -1258,8 +1257,6 @@ for more information.

A Node.js API function was called with an incompatible `this` value.

Example:

```js
const urlSearchParams = new URLSearchParams('foo=bar&baz=new');

Expand Down Expand Up @@ -1590,7 +1587,6 @@ emitted.
Prevents an abort if a string decoder was set on the Socket or if the decoder
is in `objectMode`.

Example
```js
const Socket = require('net').Socket;
const instance = new Socket();
Expand Down
37 changes: 11 additions & 26 deletions doc/api/fs.md
Original file line number Diff line number Diff line change
Expand Up @@ -1044,16 +1044,14 @@ changes:
Asynchronously append data to a file, creating the file if it does not yet
exist. `data` can be a string or a [`Buffer`][].

Example:

```js
fs.appendFile('message.txt', 'data to append', (err) => {
if (err) throw err;
console.log('The "data to append" was appended to file!');
});
```

If `options` is a string, then it specifies the encoding. Example:
If `options` is a string, then it specifies the encoding:

```js
fs.appendFile('message.txt', 'data to append', 'utf8', callback);
Expand Down Expand Up @@ -1097,8 +1095,6 @@ changes:
Synchronously append data to a file, creating the file if it does not yet
exist. `data` can be a string or a [`Buffer`][].

Example:

```js
try {
fs.appendFileSync('message.txt', 'data to append');
Expand All @@ -1108,7 +1104,7 @@ try {
}
```

If `options` is a string, then it specifies the encoding. Example:
If `options` is a string, then it specifies the encoding:

```js
fs.appendFileSync('message.txt', 'data to append', 'utf8');
Expand Down Expand Up @@ -1344,8 +1340,6 @@ fallback copy mechanism is used.
create a copy-on-write reflink. If the platform does not support copy-on-write,
then the operation will fail.

Example:

```js
const fs = require('fs');

Expand All @@ -1356,8 +1350,7 @@ fs.copyFile('source.txt', 'destination.txt', (err) => {
});
```

If the third argument is a number, then it specifies `flags`, as shown in the
following example.
If the third argument is a number, then it specifies `flags`:

```js
const fs = require('fs');
Expand Down Expand Up @@ -1395,8 +1388,6 @@ fallback copy mechanism is used.
create a copy-on-write reflink. If the platform does not support copy-on-write,
then the operation will fail.

Example:

```js
const fs = require('fs');

Expand All @@ -1405,8 +1396,7 @@ fs.copyFileSync('source.txt', 'destination.txt');
console.log('source.txt was copied to destination.txt');
```

If the third argument is a number, then it specifies `flags`, as shown in the
following example.
If the third argument is a number, then it specifies `flags`:

```js
const fs = require('fs');
Expand Down Expand Up @@ -1568,7 +1558,7 @@ deprecated: v1.0.0
* `exists` {boolean}

Test whether or not the given path exists by checking with the file system.
Then call the `callback` argument with either true or false. Example:
Then call the `callback` argument with either true or false:

```js
fs.exists('/etc/passwd', (exists) => {
Expand Down Expand Up @@ -1901,7 +1891,7 @@ fs.ftruncate(fd, 4, (err) => {
```

If the file previously was shorter than `len` bytes, it is extended, and the
extended part is filled with null bytes (`'\0'`). For example,
extended part is filled with null bytes (`'\0'`):

```js
console.log(fs.readFileSync('temp.txt', 'utf8'));
Expand Down Expand Up @@ -2505,7 +2495,7 @@ changes:
* `err` {Error}
* `data` {string|Buffer}

Asynchronously reads the entire contents of a file. Example:
Asynchronously reads the entire contents of a file.

```js
fs.readFile('/etc/passwd', (err, data) => {
Expand All @@ -2519,7 +2509,7 @@ contents of the file.

If no encoding is specified, then the raw buffer is returned.

If `options` is a string, then it specifies the encoding. Example:
If `options` is a string, then it specifies the encoding:

```js
fs.readFile('/etc/passwd', 'utf8', callback);
Expand Down Expand Up @@ -3519,8 +3509,6 @@ Asynchronously writes data to a file, replacing the file if it already exists.

The `encoding` option is ignored if `data` is a buffer.

Example:

```js
const data = new Uint8Array(Buffer.from('Hello Node.js'));
fs.writeFile('message.txt', data, (err) => {
Expand All @@ -3529,7 +3517,7 @@ fs.writeFile('message.txt', data, (err) => {
});
```

If `options` is a string, then it specifies the encoding. Example:
If `options` is a string, then it specifies the encoding:

```js
fs.writeFile('message.txt', 'Hello Node.js', 'utf8', callback);
Expand Down Expand Up @@ -3840,7 +3828,7 @@ doTruncate().catch(console.error);
```

If the file previously was shorter than `len` bytes, it is extended, and the
extended part is filled with null bytes (`'\0'`). For example,
extended part is filled with null bytes (`'\0'`):

```js
const fs = require('fs');
Expand Down Expand Up @@ -4050,8 +4038,6 @@ fallback copy mechanism is used.
create a copy-on-write reflink. If the platform does not support copy-on-write,
then the operation will fail.

Example:

```js
const fsPromises = require('fs').promises;

Expand All @@ -4061,8 +4047,7 @@ fsPromises.copyFile('source.txt', 'destination.txt')
.catch(() => console.log('The file could not be copied'));
```

If the third argument is a number, then it specifies `flags`, as shown in the
following example.
If the third argument is a number, then it specifies `flags`:

```js
const fs = require('fs');
Expand Down
Loading

0 comments on commit 1a25f96

Please sign in to comment.