Skip to content

Commit f1d92fb

Browse files
Trottaddaleax
authored andcommitted
doc: fix indentation issues in sample code
In preparation for stricter ESLint indentation checking, fix a few issues in sample code. PR-URL: #13950 Reviewed-By: Refael Ackermann <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Vse Mozhet Byt <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Tobias Nießen <[email protected]> Reviewed-By: Michael Dawson <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent f53bfe4 commit f1d92fb

File tree

8 files changed

+108
-104
lines changed

8 files changed

+108
-104
lines changed

doc/api/crypto.md

+5-3
Original file line numberDiff line numberDiff line change
@@ -586,7 +586,7 @@ const aliceSecret = alice.computeSecret(bobKey);
586586
const bobSecret = bob.computeSecret(aliceKey);
587587

588588
assert.strictEqual(aliceSecret.toString('hex'), bobSecret.toString('hex'));
589-
// OK
589+
// OK
590590
```
591591

592592
### ecdh.computeSecret(otherPublicKey[, inputEncoding][, outputEncoding])
@@ -746,10 +746,11 @@ const hash = crypto.createHash('sha256');
746746

747747
hash.on('readable', () => {
748748
const data = hash.read();
749-
if (data)
749+
if (data) {
750750
console.log(data.toString('hex'));
751751
// Prints:
752752
// 6a2da20943931e9834fc12cfe5bb47bbd9ae43489a30726962b576f4e3993e50
753+
}
753754
});
754755

755756
hash.write('some data to hash');
@@ -836,10 +837,11 @@ const hmac = crypto.createHmac('sha256', 'a secret');
836837

837838
hmac.on('readable', () => {
838839
const data = hmac.read();
839-
if (data)
840+
if (data) {
840841
console.log(data.toString('hex'));
841842
// Prints:
842843
// 7fd04df92f636fd450bc841c9418e5825c17f33ad9c87c518115a45971f7f77e
844+
}
843845
});
844846

845847
hmac.write('some data to hash');

doc/api/errors.md

+20-19
Original file line numberDiff line numberDiff line change
@@ -323,21 +323,22 @@ function makeFaster() {
323323
});
324324
}
325325

326-
makeFaster(); // will throw:
327-
// /home/gbusey/file.js:6
328-
// throw new Error('oh no!');
329-
// ^
330-
// Error: oh no!
331-
// at speedy (/home/gbusey/file.js:6:11)
332-
// at makeFaster (/home/gbusey/file.js:5:3)
333-
// at Object.<anonymous> (/home/gbusey/file.js:10:1)
334-
// at Module._compile (module.js:456:26)
335-
// at Object.Module._extensions..js (module.js:474:10)
336-
// at Module.load (module.js:356:32)
337-
// at Function.Module._load (module.js:312:12)
338-
// at Function.Module.runMain (module.js:497:10)
339-
// at startup (node.js:119:16)
340-
// at node.js:906:3
326+
makeFaster();
327+
// will throw:
328+
// /home/gbusey/file.js:6
329+
// throw new Error('oh no!');
330+
// ^
331+
// Error: oh no!
332+
// at speedy (/home/gbusey/file.js:6:11)
333+
// at makeFaster (/home/gbusey/file.js:5:3)
334+
// at Object.<anonymous> (/home/gbusey/file.js:10:1)
335+
// at Module._compile (module.js:456:26)
336+
// at Object.Module._extensions..js (module.js:474:10)
337+
// at Module.load (module.js:356:32)
338+
// at Function.Module._load (module.js:312:12)
339+
// at Function.Module.runMain (module.js:497:10)
340+
// at startup (node.js:119:16)
341+
// at node.js:906:3
341342
```
342343

343344
The location information will be one of:
@@ -368,7 +369,7 @@ For example:
368369

369370
```js
370371
require('net').connect(-1);
371-
// throws "RangeError: "port" option should be >= 0 and < 65536: -1"
372+
// throws "RangeError: "port" option should be >= 0 and < 65536: -1"
372373
```
373374

374375
Node.js will generate and throw `RangeError` instances *immediately* as a form
@@ -385,7 +386,7 @@ will do so.
385386

386387
```js
387388
doesNotExist;
388-
// throws ReferenceError, doesNotExist is not a variable in this program.
389+
// throws ReferenceError, doesNotExist is not a variable in this program.
389390
```
390391

391392
Unless an application is dynamically generating and running code,
@@ -419,7 +420,7 @@ string would be considered a TypeError.
419420

420421
```js
421422
require('url').parse(() => { });
422-
// throws TypeError, since it expected a string
423+
// throws TypeError, since it expected a string
423424
```
424425

425426
Node.js will generate and throw `TypeError` instances *immediately* as a form
@@ -640,7 +641,7 @@ const urlSearchParams = new URLSearchParams('foo=bar&baz=new');
640641

641642
const buf = Buffer.alloc(1);
642643
urlSearchParams.has.call(buf, 'foo');
643-
// Throws a TypeError with code 'ERR_INVALID_THIS'
644+
// Throws a TypeError with code 'ERR_INVALID_THIS'
644645
```
645646

646647
<a id="ERR_INVALID_TUPLE"></a>

doc/api/fs.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -235,9 +235,10 @@ support. If `filename` is provided, it will be provided as a `Buffer` if
235235
```js
236236
// Example when handled through fs.watch listener
237237
fs.watch('./tmp', { encoding: 'buffer' }, (eventType, filename) => {
238-
if (filename)
238+
if (filename) {
239239
console.log(filename);
240240
// Prints: <Buffer ...>
241+
}
241242
});
242243
```
243244

doc/api/net.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ double-backslashes, such as:
4040

4141
```js
4242
net.createServer().listen(
43-
path.join('\\\\?\\pipe', process.cwd(), 'myctl'));
43+
path.join('\\\\?\\pipe', process.cwd(), 'myctl'));
4444
```
4545

4646
## Class: net.Server

doc/api/querystring.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ in the following example:
8181
// Assuming gbkDecodeURIComponent function already exists...
8282

8383
querystring.parse('w=%D6%D0%CE%C4&foo=bar', null, null,
84-
{ decodeURIComponent: gbkDecodeURIComponent });
84+
{ decodeURIComponent: gbkDecodeURIComponent });
8585
```
8686

8787
## querystring.stringify(obj[, sep[, eq[, options]]])
@@ -125,7 +125,7 @@ following example:
125125
// Assuming gbkEncodeURIComponent function already exists,
126126

127127
querystring.stringify({ w: '中文', foo: 'bar' }, null, null,
128-
{ encodeURIComponent: gbkEncodeURIComponent });
128+
{ encodeURIComponent: gbkEncodeURIComponent });
129129
```
130130

131131
## querystring.unescape(str)

0 commit comments

Comments
 (0)