GeezerVison is showing github.com — doc: remove redundant 'Example:' and similar notes · nodejs/node@e24cd92
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: doc/api/assert.md +1-1Lines changed: 1 addition & 1 deletion - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
@@ -667,7 +667,7 @@ changes: | 667 | 667 | Throws `value` if `value` is not `undefined` or `null`. This is useful when | 668 | 668 | testing the `error` argument in callbacks. The stack trace contains all frames | 669 | 669 | from the error passed to `ifError()` including the potential new frames for | 670 | | -`ifError()` itself. See below for an example. | | 670 | +`ifError()` itself. | 671 | 671 |
| 672 | 672 | ```js | 673 | 673 | const assert = require('assert').strict; | |
Collapse file Copy file name to clipboardExpand all lines: doc/api/async_hooks.md +1-3Lines changed: 1 addition & 3 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
@@ -534,8 +534,6 @@ expensive nature of the [promise introspection API][PromiseHooks] provided by | 534 | 534 | V8. This means that programs using promises or `async`/`await` will not get | 535 | 535 | correct execution and trigger ids for promise callback contexts by default. | 536 | 536 |
| 537 | | -Here's an example: | 538 | | - | 539 | 537 | ```js | 540 | 538 | const ah = require('async_hooks'); | 541 | 539 | Promise.resolve(1729).then(() => { | @@ -551,7 +549,7 @@ the `triggerAsyncId` value is `0`, which means that we are missing context about | 551 | 549 | the resource that caused (triggered) the `then()` callback to be executed. | 552 | 550 |
| 553 | 551 | Installing async hooks via `async_hooks.createHook` enables promise execution | 554 | | -tracking. Example: | | 552 | +tracking: | 555 | 553 |
| 556 | 554 | ```js | 557 | 555 | const ah = require('async_hooks'); | |
Collapse file Copy file name to clipboardExpand all lines: doc/api/child_process.md +1-6Lines changed: 1 addition & 6 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
@@ -633,8 +633,6 @@ pipes between the parent and child. The value is one of the following: | 633 | 633 | words, stdin, stdout, and stderr) a pipe is created. For fd 3 and up, the | 634 | 634 | default is `'ignore'`. | 635 | 635 |
| 636 | | -Example: | 637 | | - | 638 | 636 | ```js | 639 | 637 | const { spawn } = require('child_process'); | 640 | 638 |
| @@ -1042,8 +1040,7 @@ See kill(2) for reference. | 1042 | 1040 |
| 1043 | 1041 | Also note: on Linux, child processes of child processes will not be terminated | 1044 | 1042 | when attempting to kill their parent. This is likely to happen when running a | 1045 | | -new process in a shell or with use of the `shell` option of `ChildProcess`, such | 1046 | | -as in this example: | | 1043 | +new process in a shell or with use of the `shell` option of `ChildProcess`: | 1047 | 1044 |
| 1048 | 1045 | ```js | 1049 | 1046 | 'use strict'; | @@ -1087,8 +1084,6 @@ added: v0.1.90 | 1087 | 1084 |
| 1088 | 1085 | Returns the process identifier (PID) of the child process. | 1089 | 1086 |
| 1090 | | -Example: | 1091 | | - | 1092 | 1087 | ```js | 1093 | 1088 | const { spawn } = require('child_process'); | 1094 | 1089 | const grep = spawn('grep', ['ssh']); | |
Collapse file Copy file name to clipboardExpand all lines: doc/api/cluster.md -2Lines changed: 0 additions & 2 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
@@ -762,8 +762,6 @@ Note that: | 762 | 762 | * The defaults above apply to the first call only, the defaults for later | 763 | 763 | calls is the current value at the time of `cluster.setupMaster()` is called. | 764 | 764 |
| 765 | | -Example: | 766 | | - | 767 | 765 | ```js | 768 | 766 | const cluster = require('cluster'); | 769 | 767 | cluster.setupMaster({ | |
Collapse file Copy file name to clipboardExpand all lines: doc/api/crypto.md +1-11Lines changed: 1 addition & 11 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
@@ -1700,8 +1700,6 @@ added: v0.9.3 | 1700 | 1700 | * Returns: {string[]} An array with the names of the supported cipher | 1701 | 1701 | algorithms. | 1702 | 1702 |
| 1703 | | -Example: | 1704 | | - | 1705 | 1703 | ```js | 1706 | 1704 | const ciphers = crypto.getCiphers(); | 1707 | 1705 | console.log(ciphers); // ['aes-128-cbc', 'aes-128-ccm', ...] | @@ -1713,8 +1711,6 @@ added: v2.3.0 | 1713 | 1711 | --> | 1714 | 1712 | * Returns: {string[]} An array with the names of the supported elliptic curves. | 1715 | 1713 |
| 1716 | | -Example: | 1717 | | - | 1718 | 1714 | ```js | 1719 | 1715 | const curves = crypto.getCurves(); | 1720 | 1716 | console.log(curves); // ['Oakley-EC2N-3', 'Oakley-EC2N-4', ...] | @@ -1733,7 +1729,7 @@ supported groups are: `'modp1'`, `'modp2'`, `'modp5'` (defined in | 1733 | 1729 | `'modp16'`, `'modp17'`, `'modp18'` (defined in [RFC 3526][]). The | 1734 | 1730 | returned object mimics the interface of objects created by | 1735 | 1731 | [`crypto.createDiffieHellman()`][], but will not allow changing | 1736 | | -the keys (with [`diffieHellman.setPublicKey()`][] for example). The | | 1732 | +the keys (with [`diffieHellman.setPublicKey()`][], for example). The | 1737 | 1733 | advantage of using this method is that the parties do not have to | 1738 | 1734 | generate nor exchange a group modulus beforehand, saving both processor | 1739 | 1735 | and communication time. | @@ -1769,8 +1765,6 @@ added: v0.9.3 | 1769 | 1765 | * Returns: {string[]} An array of the names of the supported hash algorithms, | 1770 | 1766 | such as `'RSA-SHA256'`. | 1771 | 1767 |
| 1772 | | -Example: | 1773 | | - | 1774 | 1768 | ```js | 1775 | 1769 | const hashes = crypto.getHashes(); | 1776 | 1770 | console.log(hashes); // ['DSA', 'DSA-SHA', 'DSA-SHA1', ...] | @@ -1819,8 +1813,6 @@ but will take a longer amount of time to complete. | 1819 | 1813 | The `salt` should be as unique as possible. It is recommended that a salt is | 1820 | 1814 | random and at least 16 bytes long. See [NIST SP 800-132][] for details. | 1821 | 1815 |
| 1822 | | -Example: | 1823 | | - | 1824 | 1816 | ```js | 1825 | 1817 | const crypto = require('crypto'); | 1826 | 1818 | crypto.pbkdf2('secret', 'salt', 100000, 64, 'sha512', (err, derivedKey) => { | @@ -1884,8 +1876,6 @@ but will take a longer amount of time to complete. | 1884 | 1876 | The `salt` should be as unique as possible. It is recommended that a salt is | 1885 | 1877 | random and at least 16 bytes long. See [NIST SP 800-132][] for details. | 1886 | 1878 |
| 1887 | | -Example: | 1888 | | - | 1889 | 1879 | ```js | 1890 | 1880 | const crypto = require('crypto'); | 1891 | 1881 | const key = crypto.pbkdf2Sync('secret', 'salt', 100000, 64, 'sha512'); | |
Collapse file Copy file name to clipboardExpand all lines: doc/api/dgram.md +3-4Lines changed: 3 additions & 4 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
@@ -546,17 +546,16 @@ chained. | 546 | 546 | ### Change to asynchronous `socket.bind()` behavior | 547 | 547 |
| 548 | 548 | As of Node.js v0.10, [`dgram.Socket#bind()`][] changed to an asynchronous | 549 | | -execution model. Legacy code that assumes synchronous behavior, as in the | 550 | | -following example: | | 549 | +execution model. Legacy code would use synchronous behavior: | 551 | 550 |
| 552 | 551 | ```js | 553 | 552 | const s = dgram.createSocket('udp4'); | 554 | 553 | s.bind(1234); | 555 | 554 | s.addMembership('224.0.0.114'); | 556 | 555 | ``` | 557 | 556 |
| 558 | | -Must be changed to pass a callback function to the [`dgram.Socket#bind()`][] | 559 | | -function: | | 557 | +Such legacy code would need to be changed to pass a callback function to the | | 558 | +[`dgram.Socket#bind()`][] function: | 560 | 559 |
| 561 | 560 | ```js | 562 | 561 | const s = dgram.createSocket('udp4'); | |
Collapse file Copy file name to clipboardExpand all lines: doc/api/domain.md -6Lines changed: 0 additions & 6 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
@@ -311,8 +311,6 @@ The returned function will be a wrapper around the supplied callback | 311 | 311 | function. When the returned function is called, any errors that are | 312 | 312 | thrown will be routed to the domain's `'error'` event. | 313 | 313 |
| 314 | | -#### Example | 315 | | - | 316 | 314 | ```js | 317 | 315 | const d = domain.create(); | 318 | 316 |
| @@ -370,8 +368,6 @@ objects sent as the first argument to the function. | 370 | 368 | In this way, the common `if (err) return callback(err);` pattern can be replaced | 371 | 369 | with a single error handler in a single place. | 372 | 370 |
| 373 | | -#### Example | 374 | | - | 375 | 371 | ```js | 376 | 372 | const d = domain.create(); | 377 | 373 |
| @@ -415,8 +411,6 @@ the function. | 415 | 411 |
| 416 | 412 | This is the most basic way to use a domain. | 417 | 413 |
| 418 | | -Example: | 419 | | - | 420 | 414 | ```js | 421 | 415 | const domain = require('domain'); | 422 | 416 | const fs = require('fs'); | |
Collapse file Copy file name to clipboardExpand all lines: doc/api/errors.md +1-5Lines changed: 1 addition & 5 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
@@ -1253,8 +1253,7 @@ type for one of its returned object properties on execution. | 1253 | 1253 | ### ERR_INVALID_RETURN_VALUE | 1254 | 1254 |
| 1255 | 1255 | Thrown in case a function option does not return an expected value | 1256 | | -type on execution. | 1257 | | -For example when a function is expected to return a promise. | | 1256 | +type on execution, such as when a function is expected to return a promise. | 1258 | 1257 |
| 1259 | 1258 | <a id="ERR_INVALID_SYNC_FORK_INPUT"></a> | 1260 | 1259 | ### ERR_INVALID_SYNC_FORK_INPUT | @@ -1268,8 +1267,6 @@ for more information. | 1268 | 1267 |
| 1269 | 1268 | A Node.js API function was called with an incompatible `this` value. | 1270 | 1269 |
| 1271 | | -Example: | 1272 | | - | 1273 | 1270 | ```js | 1274 | 1271 | const urlSearchParams = new URLSearchParams('foo=bar&baz=new'); | 1275 | 1272 |
| @@ -1595,7 +1592,6 @@ emitted. | 1595 | 1592 | Prevents an abort if a string decoder was set on the Socket or if the decoder | 1596 | 1593 | is in `objectMode`. | 1597 | 1594 |
| 1598 | | -Example | 1599 | 1595 | ```js | 1600 | 1596 | const Socket = require('net').Socket; | 1601 | 1597 | const instance = new Socket(); | |
Collapse file Copy file name to clipboardExpand all lines: doc/api/fs.md +11-26Lines changed: 11 additions & 26 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
@@ -1044,16 +1044,14 @@ changes: | 1044 | 1044 | Asynchronously append data to a file, creating the file if it does not yet | 1045 | 1045 | exist. `data` can be a string or a [`Buffer`][]. | 1046 | 1046 |
| 1047 | | -Example: | 1048 | | - | 1049 | 1047 | ```js | 1050 | 1048 | fs.appendFile('message.txt', 'data to append', (err) => { | 1051 | 1049 | if (err) throw err; | 1052 | 1050 | console.log('The "data to append" was appended to file!'); | 1053 | 1051 | }); | 1054 | 1052 | ``` | 1055 | 1053 |
| 1056 | | -If `options` is a string, then it specifies the encoding. Example: | | 1054 | +If `options` is a string, then it specifies the encoding: | 1057 | 1055 |
| 1058 | 1056 | ```js | 1059 | 1057 | fs.appendFile('message.txt', 'data to append', 'utf8', callback); | @@ -1097,8 +1095,6 @@ changes: | 1097 | 1095 | Synchronously append data to a file, creating the file if it does not yet | 1098 | 1096 | exist. `data` can be a string or a [`Buffer`][]. | 1099 | 1097 |
| 1100 | | -Example: | 1101 | | - | 1102 | 1098 | ```js | 1103 | 1099 | try { | 1104 | 1100 | fs.appendFileSync('message.txt', 'data to append'); | @@ -1108,7 +1104,7 @@ try { | 1108 | 1104 | } | 1109 | 1105 | ``` | 1110 | 1106 |
| 1111 | | -If `options` is a string, then it specifies the encoding. Example: | | 1107 | +If `options` is a string, then it specifies the encoding: | 1112 | 1108 |
| 1113 | 1109 | ```js | 1114 | 1110 | fs.appendFileSync('message.txt', 'data to append', 'utf8'); | @@ -1344,8 +1340,6 @@ fallback copy mechanism is used. | 1344 | 1340 | create a copy-on-write reflink. If the platform does not support copy-on-write, | 1345 | 1341 | then the operation will fail. | 1346 | 1342 |
| 1347 | | -Example: | 1348 | | - | 1349 | 1343 | ```js | 1350 | 1344 | const fs = require('fs'); | 1351 | 1345 |
| @@ -1356,8 +1350,7 @@ fs.copyFile('source.txt', 'destination.txt', (err) => { | 1356 | 1350 | }); | 1357 | 1351 | ``` | 1358 | 1352 |
| 1359 | | -If the third argument is a number, then it specifies `flags`, as shown in the | 1360 | | -following example. | | 1353 | +If the third argument is a number, then it specifies `flags`: | 1361 | 1354 |
| 1362 | 1355 | ```js | 1363 | 1356 | const fs = require('fs'); | @@ -1395,8 +1388,6 @@ fallback copy mechanism is used. | 1395 | 1388 | create a copy-on-write reflink. If the platform does not support copy-on-write, | 1396 | 1389 | then the operation will fail. | 1397 | 1390 |
| 1398 | | -Example: | 1399 | | - | 1400 | 1391 | ```js | 1401 | 1392 | const fs = require('fs'); | 1402 | 1393 |
| @@ -1405,8 +1396,7 @@ fs.copyFileSync('source.txt', 'destination.txt'); | 1405 | 1396 | console.log('source.txt was copied to destination.txt'); | 1406 | 1397 | ``` | 1407 | 1398 |
| 1408 | | -If the third argument is a number, then it specifies `flags`, as shown in the | 1409 | | -following example. | | 1399 | +If the third argument is a number, then it specifies `flags`: | 1410 | 1400 |
| 1411 | 1401 | ```js | 1412 | 1402 | const fs = require('fs'); | @@ -1563,7 +1553,7 @@ deprecated: v1.0.0 | 1563 | 1553 | * `exists` {boolean} | 1564 | 1554 |
| 1565 | 1555 | Test whether or not the given path exists by checking with the file system. | 1566 | | -Then call the `callback` argument with either true or false. Example: | | 1556 | +Then call the `callback` argument with either true or false: | 1567 | 1557 |
| 1568 | 1558 | ```js | 1569 | 1559 | fs.exists('/etc/passwd', (exists) => { | @@ -1896,7 +1886,7 @@ fs.ftruncate(fd, 4, (err) => { | 1896 | 1886 | ``` | 1897 | 1887 |
| 1898 | 1888 | If the file previously was shorter than `len` bytes, it is extended, and the | 1899 | | -extended part is filled with null bytes (`'\0'`). For example, | | 1889 | +extended part is filled with null bytes (`'\0'`): | 1900 | 1890 |
| 1901 | 1891 | ```js | 1902 | 1892 | console.log(fs.readFileSync('temp.txt', 'utf8')); | @@ -2485,7 +2475,7 @@ changes: | 2485 | 2475 | * `err` {Error} | 2486 | 2476 | * `data` {string|Buffer} | 2487 | 2477 |
| 2488 | | -Asynchronously reads the entire contents of a file. Example: | | 2478 | +Asynchronously reads the entire contents of a file. | 2489 | 2479 |
| 2490 | 2480 | ```js | 2491 | 2481 | fs.readFile('/etc/passwd', (err, data) => { | @@ -2499,7 +2489,7 @@ contents of the file. | 2499 | 2489 |
| 2500 | 2490 | If no encoding is specified, then the raw buffer is returned. | 2501 | 2491 |
| 2502 | | -If `options` is a string, then it specifies the encoding. Example: | | 2492 | +If `options` is a string, then it specifies the encoding: | 2503 | 2493 |
| 2504 | 2494 | ```js | 2505 | 2495 | fs.readFile('/etc/passwd', 'utf8', callback); | @@ -3499,8 +3489,6 @@ Asynchronously writes data to a file, replacing the file if it already exists. | 3499 | 3489 |
| 3500 | 3490 | The `encoding` option is ignored if `data` is a buffer. | 3501 | 3491 |
| 3502 | | -Example: | 3503 | | - | 3504 | 3492 | ```js | 3505 | 3493 | const data = new Uint8Array(Buffer.from('Hello Node.js')); | 3506 | 3494 | fs.writeFile('message.txt', data, (err) => { | @@ -3509,7 +3497,7 @@ fs.writeFile('message.txt', data, (err) => { | 3509 | 3497 | }); | 3510 | 3498 | ``` | 3511 | 3499 |
| 3512 | | -If `options` is a string, then it specifies the encoding. Example: | | 3500 | +If `options` is a string, then it specifies the encoding: | 3513 | 3501 |
| 3514 | 3502 | ```js | 3515 | 3503 | fs.writeFile('message.txt', 'Hello Node.js', 'utf8', callback); | @@ -3820,7 +3808,7 @@ doTruncate().catch(console.error); | 3820 | 3808 | ``` | 3821 | 3809 |
| 3822 | 3810 | If the file previously was shorter than `len` bytes, it is extended, and the | 3823 | | -extended part is filled with null bytes (`'\0'`). For example, | | 3811 | +extended part is filled with null bytes (`'\0'`): | 3824 | 3812 |
| 3825 | 3813 | ```js | 3826 | 3814 | const fs = require('fs'); | @@ -4030,8 +4018,6 @@ fallback copy mechanism is used. | 4030 | 4018 | create a copy-on-write reflink. If the platform does not support copy-on-write, | 4031 | 4019 | then the operation will fail. | 4032 | 4020 |
| 4033 | | -Example: | 4034 | | - | 4035 | 4021 | ```js | 4036 | 4022 | const fsPromises = require('fs').promises; | 4037 | 4023 |
| @@ -4041,8 +4027,7 @@ fsPromises.copyFile('source.txt', 'destination.txt') | 4041 | 4027 | .catch(() => console.log('The file could not be copied')); | 4042 | 4028 | ``` | 4043 | 4029 |
| 4044 | | -If the third argument is a number, then it specifies `flags`, as shown in the | 4045 | | -following example. | | 4030 | +If the third argument is a number, then it specifies `flags`: | 4046 | 4031 |
| 4047 | 4032 | ```js | 4048 | 4033 | const fs = require('fs'); | |
|