Skip to content

Commit b08a867

Browse files
committed
benchmark,doc,lib: capitalize more comments
PR-URL: #26849 Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Vse Mozhet Byt <[email protected]>
1 parent fd992e6 commit b08a867

File tree

232 files changed

+466
-473
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

232 files changed

+466
-473
lines changed

benchmark/_cli.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ function CLI(usage, settings) {
1616
if (!(this instanceof CLI)) return new CLI(usage, settings);
1717

1818
if (process.argv.length < 3) {
19-
this.abort(usage); // abort will exit the process
19+
this.abort(usage); // Abort will exit the process
2020
}
2121

2222
this.usage = usage;

benchmark/common.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ Benchmark.prototype.end = function(operations) {
202202
if (elapsed[0] === 0 && elapsed[1] === 0) {
203203
if (!process.env.NODEJS_BENCHMARK_ZERO_ALLOWED)
204204
throw new Error('insufficient clock precision for short benchmark');
205-
// avoid dividing by zero
205+
// Avoid dividing by zero
206206
elapsed[1] = 1;
207207
}
208208

benchmark/crypto/hash-stream-creation.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// throughput benchmark
1+
// Throughput benchmark
22
// creates a single hasher, then pushes a bunch of data through it
33
'use strict';
44
const common = require('../common.js');

benchmark/crypto/hash-stream-throughput.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// throughput benchmark
1+
// Throughput benchmark
22
// creates a single hasher, then pushes a bunch of data through it
33
'use strict';
44
const common = require('../common.js');

benchmark/fixtures/simple-http-server.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const storedUnicode = Object.create(null);
99

1010
const useDomains = process.env.NODE_USE_DOMAINS;
1111

12-
// set up one global domain.
12+
// Set up one global domain.
1313
if (useDomains) {
1414
var domain = require('domain');
1515
const gdom = domain.create();

benchmark/http/cluster.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const PORT = common.PORT;
55
const cluster = require('cluster');
66
if (cluster.isMaster) {
77
var bench = common.createBenchmark(main, {
8-
// unicode confuses ab on os x.
8+
// Unicode confuses ab on os x.
99
type: ['bytes', 'buffer'],
1010
len: [4, 1024, 102400],
1111
c: [50, 500]

benchmark/http/incoming_headers.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ const common = require('../common.js');
33
const http = require('http');
44

55
const bench = common.createBenchmark(main, {
6-
// unicode confuses ab on os x.
6+
// Unicode confuses ab on os x.
77
c: [50, 500],
88
n: [0, 5, 20]
99
});

benchmark/http/simple.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
const common = require('../common.js');
33

44
const bench = common.createBenchmark(main, {
5-
// unicode confuses ab on os x.
5+
// Unicode confuses ab on os x.
66
type: ['bytes', 'buffer'],
77
len: [4, 1024, 102400],
88
chunks: [1, 4],

benchmark/net/net-c2s-cork.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ function main({ dur, len, type }) {
3333

3434
const writer = new Writer();
3535

36-
// the actual benchmark.
36+
// The actual benchmark.
3737
const server = net.createServer((socket) => {
3838
socket.pipe(writer);
3939
});

benchmark/net/net-c2s.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ function main({ dur, len, type }) {
3434
const reader = new Reader();
3535
const writer = new Writer();
3636

37-
// the actual benchmark.
37+
// The actual benchmark.
3838
const server = net.createServer((socket) => {
3939
socket.pipe(writer);
4040
});

benchmark/net/net-pipe.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ function main({ dur, len, type }) {
3434
const reader = new Reader();
3535
const writer = new Writer();
3636

37-
// the actual benchmark.
37+
// The actual benchmark.
3838
const server = net.createServer((socket) => {
3939
socket.pipe(socket);
4040
});

benchmark/net/net-s2c.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ function main({ dur, len, type }) {
3333
const reader = new Reader();
3434
const writer = new Writer();
3535

36-
// the actual benchmark.
36+
// The actual benchmark.
3737
const server = net.createServer((socket) => {
3838
reader.pipe(socket);
3939
});

benchmark/net/net-wrap-js-stream-passthrough.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ function main({ dur, len, type }) {
3838
const reader = new Reader();
3939
const writer = new Writer();
4040

41-
// the actual benchmark.
41+
// The actual benchmark.
4242
const fakeSocket = new JSStreamWrap(new PassThrough());
4343
bench.start();
4444
reader.pipe(fakeSocket);

benchmark/url/legacy-vs-whatwg-url-parse.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const bench = common.createBenchmark(main, {
1313

1414
function useLegacy(data) {
1515
const len = data.length;
16-
var result = url.parse(data[0]); // avoid dead code elimination
16+
var result = url.parse(data[0]); // Avoid dead code elimination
1717
bench.start();
1818
for (var i = 0; i < len; ++i) {
1919
result = url.parse(data[i]);
@@ -24,7 +24,7 @@ function useLegacy(data) {
2424

2525
function useWHATWGWithBase(data) {
2626
const len = data.length;
27-
var result = new URL(data[0][0], data[0][1]); // avoid dead code elimination
27+
var result = new URL(data[0][0], data[0][1]); // Avoid dead code elimination
2828
bench.start();
2929
for (var i = 0; i < len; ++i) {
3030
const item = data[i];
@@ -36,7 +36,7 @@ function useWHATWGWithBase(data) {
3636

3737
function useWHATWGWithoutBase(data) {
3838
const len = data.length;
39-
var result = new URL(data[0]); // avoid dead code elimination
39+
var result = new URL(data[0]); // Avoid dead code elimination
4040
bench.start();
4141
for (var i = 0; i < len; ++i) {
4242
result = new URL(data[i]);

benchmark/url/url-searchparams-sort.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ const common = require('../common.js');
33
const URLSearchParams = require('url').URLSearchParams;
44

55
const inputs = {
6-
wpt: 'wpt', // to work around tests
6+
wpt: 'wpt', // To work around tests
77
empty: '',
88
sorted: 'a&b&c&d&e&f&g&h&i&j&k&l&m&n&o&p&q&r&s&t&u&v&w&x&y&z',
99
almostsorted: 'a&b&c&d&e&f&g&i&h&j&k&l&m&n&o&p&q&r&s&t&u&w&v&x&y&z',

doc/api/cluster.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ if (cluster.isMaster) {
315315
} else if (cluster.isWorker) {
316316
const net = require('net');
317317
const server = net.createServer((socket) => {
318-
// connections never end
318+
// Connections never end
319319
});
320320

321321
server.listen(8000);

doc/api/console.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -114,12 +114,12 @@ error output. If `stderr` is not provided, `stdout` is used for `stderr`.
114114
```js
115115
const output = fs.createWriteStream('./stdout.log');
116116
const errorOutput = fs.createWriteStream('./stderr.log');
117-
// custom simple logger
117+
// Custom simple logger
118118
const logger = new Console({ stdout: output, stderr: errorOutput });
119119
// use it like console
120120
const count = 5;
121121
logger.log('count: %d', count);
122-
// in stdout.log: count 5
122+
// In stdout.log: count 5
123123
```
124124

125125
The global `console` is a special `Console` whose output is sent to

doc/api/domain.md

+5-7
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ if (cluster.isMaster) {
135135
// But don't keep the process open just for that!
136136
killtimer.unref();
137137

138-
// stop taking new requests.
138+
// Stop taking new requests.
139139
server.close();
140140

141141
// Let the master know we're dead. This will trigger a
@@ -316,14 +316,13 @@ const d = domain.create();
316316

317317
function readSomeFile(filename, cb) {
318318
fs.readFile(filename, 'utf8', d.bind((er, data) => {
319-
// If this throws, it will also be passed to the domain
319+
// If this throws, it will also be passed to the domain.
320320
return cb(er, data ? JSON.parse(data) : null);
321321
}));
322322
}
323323

324324
d.on('error', (er) => {
325-
// an error occurred somewhere.
326-
// if we throw it now, it will crash the program
325+
// An error occurred somewhere. If we throw it now, it will crash the program
327326
// with the normal line number and stack message.
328327
});
329328
```
@@ -377,7 +376,7 @@ function readSomeFile(filename, cb) {
377376
// callback since it is assumed to be the 'Error' argument
378377
// and thus intercepted by the domain.
379378

380-
// if this throws, it will also be passed to the domain
379+
// If this throws, it will also be passed to the domain
381380
// so the error-handling logic can be moved to the 'error'
382381
// event on the domain instead of being repeated throughout
383382
// the program.
@@ -386,8 +385,7 @@ function readSomeFile(filename, cb) {
386385
}
387386

388387
d.on('error', (er) => {
389-
// an error occurred somewhere.
390-
// if we throw it now, it will crash the program
388+
// An error occurred somewhere. If we throw it now, it will crash the program
391389
// with the normal line number and stack message.
392390
});
393391
```

doc/api/errors.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@ program.
407407
try {
408408
require('vm').runInThisContext('binary ! isNotOk');
409409
} catch (err) {
410-
// err will be a SyntaxError
410+
// 'err' will be a SyntaxError.
411411
}
412412
```
413413

@@ -422,7 +422,7 @@ string would be considered a `TypeError`.
422422

423423
```js
424424
require('url').parse(() => { });
425-
// throws TypeError, since it expected a string
425+
// Throws TypeError, since it expected a string.
426426
```
427427

428428
Node.js will generate and throw `TypeError` instances *immediately* as a form

doc/api/events.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -648,7 +648,7 @@ emitter.on('log', () => console.log('log persistently'));
648648
// Will return a new Array with a single function bound by `.on()` above
649649
const newListeners = emitter.rawListeners('log');
650650

651-
// logs "log persistently" twice
651+
// Logs "log persistently" twice
652652
newListeners[0]();
653653
emitter.emit('log');
654654
```

doc/api/http.md

+8-8
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ const proxy = http.createServer((req, res) => {
358358
res.end('okay');
359359
});
360360
proxy.on('connect', (req, cltSocket, head) => {
361-
// connect to an origin server
361+
// Connect to an origin server
362362
const srvUrl = url.parse(`http://${req.url}`);
363363
const srvSocket = net.connect(srvUrl.port, srvUrl.hostname, () => {
364364
cltSocket.write('HTTP/1.1 200 Connection Established\r\n' +
@@ -370,7 +370,7 @@ proxy.on('connect', (req, cltSocket, head) => {
370370
});
371371
});
372372

373-
// now that proxy is running
373+
// Now that proxy is running
374374
proxy.listen(1337, '127.0.0.1', () => {
375375

376376
// Make a request to a tunneling proxy
@@ -504,7 +504,7 @@ srv.on('upgrade', (req, socket, head) => {
504504
socket.pipe(socket); // echo back
505505
});
506506

507-
// now that server is running
507+
// Now that server is running
508508
srv.listen(1337, '127.0.0.1', () => {
509509

510510
// make a request
@@ -626,11 +626,11 @@ request.setHeader('content-type', 'text/html');
626626
request.setHeader('Content-Length', Buffer.byteLength(body));
627627
request.setHeader('Cookie', ['type=ninja', 'language=javascript']);
628628
const contentType = request.getHeader('Content-Type');
629-
// contentType is 'text/html'
629+
// 'contentType' is 'text/html'
630630
const contentLength = request.getHeader('Content-Length');
631-
// contentLength is of type number
631+
// 'contentLength' is of type number
632632
const cookie = request.getHeader('Cookie');
633-
// cookie is of type string[]
633+
// 'cookie' is of type string[]
634634
```
635635

636636
### request.maxHeadersCount
@@ -745,7 +745,7 @@ req.once('response', (res) => {
745745
const ip = req.socket.localAddress;
746746
const port = req.socket.localPort;
747747
console.log(`Your IP address is ${ip} and your source port is ${port}.`);
748-
// consume response object
748+
// Consume response object
749749
});
750750
```
751751

@@ -2065,7 +2065,7 @@ req.on('error', (e) => {
20652065
console.error(`problem with request: ${e.message}`);
20662066
});
20672067

2068-
// write data to request body
2068+
// Write data to request body
20692069
req.write(postData);
20702070
req.end();
20712071
```

doc/api/http2.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -2437,7 +2437,7 @@ const client = http2.connect('http://localhost');
24372437

24382438
client.on('stream', (pushedStream, requestHeaders) => {
24392439
pushedStream.on('push', (responseHeaders) => {
2440-
// process response headers
2440+
// Process response headers
24412441
});
24422442
pushedStream.on('data', (chunk) => { /* handle pushed data */ });
24432443
});

doc/api/process.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -295,8 +295,8 @@ process.on('unhandledRejection', (reason, p) => {
295295
});
296296

297297
somePromise.then((res) => {
298-
return reportToUser(JSON.pasre(res)); // note the typo (`pasre`)
299-
}); // no `.catch()` or `.then()`
298+
return reportToUser(JSON.pasre(res)); // Note the typo (`pasre`)
299+
}); // No `.catch()` or `.then()`
300300
```
301301

302302
The following will also trigger the `'unhandledRejection'` event to be

doc/api/querystring.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ querystring.stringify({ foo: 'bar', baz: ['qux', 'quux'], corge: '' });
126126
// Returns 'foo=bar&baz=qux&baz=quux&corge='
127127

128128
querystring.stringify({ foo: 'bar', baz: 'qux' }, ';', ':');
129-
// returns 'foo:bar;baz:qux'
129+
// Returns 'foo:bar;baz:qux'
130130
```
131131

132132
By default, characters requiring percent-encoding within the query string will

doc/api/stream.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -683,7 +683,7 @@ pass.unpipe(writable);
683683
// readableFlowing is now false
684684

685685
pass.on('data', (chunk) => { console.log(chunk.toString()); });
686-
pass.write('ok'); // will not emit 'data'
686+
pass.write('ok'); // Will not emit 'data'
687687
pass.resume(); // Must be called to make stream emit 'data'
688688
```
689689

@@ -1206,7 +1206,7 @@ function parseHeader(stream, callback) {
12061206
while (null !== (chunk = stream.read())) {
12071207
const str = decoder.write(chunk);
12081208
if (str.match(/\n\n/)) {
1209-
// found the header boundary
1209+
// Found the header boundary
12101210
const split = str.split(/\n\n/);
12111211
header += split.shift();
12121212
const remaining = split.join('\n\n');
@@ -1219,7 +1219,7 @@ function parseHeader(stream, callback) {
12191219
// Now the body of the message can be read from the stream.
12201220
callback(null, header, stream);
12211221
} else {
1222-
// still reading the header.
1222+
// Still reading the header.
12231223
header += str;
12241224
}
12251225
}

doc/api/timers.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ setImmediatePromise('foobar').then((value) => {
163163
// This is executed after all I/O callbacks.
164164
});
165165

166-
// or with async function
166+
// Or with async function
167167
async function timerExample() {
168168
console.log('Before I/O callbacks');
169169
await setImmediatePromise();

doc/api/util.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -758,7 +758,7 @@ option properties directly is also supported.
758758
const util = require('util');
759759
const arr = Array(101).fill(0);
760760

761-
console.log(arr); // logs the truncated array
761+
console.log(arr); // Logs the truncated array
762762
util.inspect.defaultOptions.maxArrayLength = null;
763763
console.log(arr); // logs the full array
764764
```

doc/api/zlib.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ See [Memory Usage Tuning][] for more information on the speed/memory/compression
6969
tradeoffs involved in `zlib` usage.
7070

7171
```js
72-
// client request example
72+
// Client request example
7373
const zlib = require('zlib');
7474
const http = require('http');
7575
const fs = require('fs');

0 commit comments

Comments
 (0)