Skip to content

Commit 1f00359

Browse files
saadqevanlucas
authored andcommitted
doc: fix inconsistencies in code style
Adds missing semicolons, removes extra white space, and properly indents various code snippets in the documentation. Reviewed-By: Evan Lucas <[email protected]> Reviewed-By: targos - Michaël Zasso <[email protected]> PR-URL: #7745
1 parent 49a6ea1 commit 1f00359

11 files changed

+24
-24
lines changed

doc/api/assert.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ const obj3 = {
7171
a : {
7272
b : 1
7373
}
74-
}
74+
};
7575
const obj4 = Object.create(obj1);
7676

7777
assert.deepEqual(obj1, obj1);
@@ -230,7 +230,7 @@ const assert = require('assert');
230230

231231
assert.ifError(0); // OK
232232
assert.ifError(1); // Throws 1
233-
assert.ifError('error') // Throws 'error'
233+
assert.ifError('error'); // Throws 'error'
234234
assert.ifError(new Error()); // Throws Error
235235
```
236236

doc/api/buffer.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ Buffers can be iterated over using the ECMAScript 2015 (ES6) `for..of` syntax:
247247
const buf = Buffer.from([1, 2, 3]);
248248

249249
for (var b of buf)
250-
console.log(b)
250+
console.log(b);
251251

252252
// Prints:
253253
// 1

doc/api/crypto.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ var decrypted = '';
236236
decipher.on('readable', () => {
237237
var data = decipher.read();
238238
if (data)
239-
decrypted += data.toString('utf8');
239+
decrypted += data.toString('utf8');
240240
});
241241
decipher.on('end', () => {
242242
console.log(decrypted);

doc/api/fs.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1022,12 +1022,12 @@ will be returned._
10221022
// OS X and Linux
10231023
fs.open('<directory>', 'a+', (err, fd) => {
10241024
// => [Error: EISDIR: illegal operation on a directory, open <directory>]
1025-
})
1025+
});
10261026

10271027
// Windows and FreeBSD
10281028
fs.open('<directory>', 'a+', (err, fd) => {
10291029
// => null, <fd>
1030-
})
1030+
});
10311031
```
10321032

10331033
## fs.openSync(path, flags[, mode])

doc/api/http.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ http.get({
9090
agent: false // create a new agent just for this one request
9191
}, (res) => {
9292
// Do stuff with response
93-
})
93+
});
9494
```
9595

9696
### new Agent([options])
@@ -1451,8 +1451,8 @@ var req = http.request(options, (res) => {
14511451
console.log(`BODY: ${chunk}`);
14521452
});
14531453
res.on('end', () => {
1454-
console.log('No more data in response.')
1455-
})
1454+
console.log('No more data in response.');
1455+
});
14561456
});
14571457

14581458
req.on('error', (e) => {

doc/api/https.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ options.agent = new https.Agent(options);
231231

232232
var req = https.request(options, (res) => {
233233
...
234-
}
234+
});
235235
```
236236

237237
Alternatively, opt out of connection pooling by not using an `Agent`.
@@ -251,7 +251,7 @@ var options = {
251251

252252
var req = https.request(options, (res) => {
253253
...
254-
}
254+
});
255255
```
256256

257257
[`Agent`]: #https_class_https_agent

doc/api/path.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ path.format({
234234
base : "file.txt",
235235
ext : ".txt",
236236
name : "file"
237-
})
237+
});
238238
// returns 'C:\\path\\dir\\file.txt'
239239
```
240240

doc/api/readline.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -398,10 +398,10 @@ For instance: `[[substr1, substr2, ...], originalsubstring]`.
398398

399399
```js
400400
function completer(line) {
401-
var completions = '.help .error .exit .quit .q'.split(' ')
402-
var hits = completions.filter((c) => { return c.indexOf(line) == 0 })
401+
var completions = '.help .error .exit .quit .q'.split(' ');
402+
var hits = completions.filter((c) => { return c.indexOf(line) == 0 });
403403
// show all completions if none found
404-
return [hits.length ? hits : completions, line]
404+
return [hits.length ? hits : completions, line];
405405
}
406406
```
407407

doc/api/repl.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,7 @@ net.createServer((socket) => {
492492
output: socket
493493
}).on('exit', () => {
494494
socket.end();
495-
})
495+
});
496496
}).listen('/tmp/node-repl-sock');
497497

498498
net.createServer((socket) => {

doc/api/stream.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -1227,9 +1227,9 @@ const Writable = require('stream').Writable;
12271227
const myWritable = new Writable({
12281228
write(chunk, encoding, callback) {
12291229
if (chunk.toString().indexOf('a') >= 0) {
1230-
callback(new Error('chunk is invalid'))
1230+
callback(new Error('chunk is invalid'));
12311231
} else {
1232-
callback()
1232+
callback();
12331233
}
12341234
}
12351235
});
@@ -1252,9 +1252,9 @@ class MyWritable extends Writable {
12521252

12531253
_write(chunk, encoding, callback) {
12541254
if (chunk.toString().indexOf('a') >= 0) {
1255-
callback(new Error('chunk is invalid'))
1255+
callback(new Error('chunk is invalid'));
12561256
} else {
1257-
callback()
1257+
callback();
12581258
}
12591259
}
12601260
}

doc/api/util.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -145,14 +145,14 @@ const util = require('util');
145145
const EventEmitter = require('events');
146146

147147
function MyStream() {
148-
EventEmitter.call(this);
148+
EventEmitter.call(this);
149149
}
150150

151151
util.inherits(MyStream, EventEmitter);
152152

153153
MyStream.prototype.write = function(data) {
154-
this.emit('data', data);
155-
}
154+
this.emit('data', data);
155+
};
156156

157157
const stream = new MyStream();
158158

@@ -161,7 +161,7 @@ console.log(MyStream.super_ === EventEmitter); // true
161161

162162
stream.on('data', (data) => {
163163
console.log(`Received data: "${data}"`);
164-
})
164+
});
165165
stream.write('It works!'); // Received data: "It works!"
166166
```
167167

0 commit comments

Comments
 (0)