Skip to content

Commit

Permalink
benchmark,doc,lib,test: capitalize comments
Browse files Browse the repository at this point in the history
This updates a lot of comments.

PR-URL: #26223
Reviewed-By: Rich Trott <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Vse Mozhet Byt <[email protected]>
Reviewed-By: Anto Aravinth <[email protected]>
  • Loading branch information
BridgeAR committed Mar 4, 2019
1 parent 3f4b27d commit d66cb4a
Show file tree
Hide file tree
Showing 202 changed files with 348 additions and 349 deletions.
4 changes: 2 additions & 2 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ module.exports = {
'brace-style': ['error', '1tbs', { allowSingleLine: true }],
'capitalized-comments': ['error', 'always', {
line: {
// Ignore all lines that have less characters than 50 and all lines that
// Ignore all lines that have less characters than 40 and all lines that
// start with something that looks like a variable name or code.
ignorePattern: '^.{0,50}$|^ [a-z]+ ?[0-9A-Z_.(/=:[#-]',
ignorePattern: '^.{0,40}$|^ [a-z]+ ?[0-9A-Z_.(/=:[#-]|^ std',
ignoreInlineComments: true,
ignoreConsecutiveComments: true,
},
Expand Down
4 changes: 2 additions & 2 deletions benchmark/_cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ function CLI(usage, settings) {
}

let currentOptional = null;
let mode = 'both'; // possible states are: [both, option, item]
let mode = 'both'; // Possible states are: [both, option, item]

for (const arg of process.argv.slice(2)) {
if (arg === '--') {
Expand Down Expand Up @@ -59,7 +59,7 @@ function CLI(usage, settings) {
this.optional[currentOptional] = arg;
}

// the next value can be either an option or an item
// The next value can be either an option or an item
mode = 'both';
} else if (['both', 'item'].includes(mode)) {
// item arguments
Expand Down
2 changes: 1 addition & 1 deletion benchmark/crypto/cipher-stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ function main({ api, cipher, type, len, writes }) {
cipher = 'AES192';
if (api === 'stream' && /^v0\.[0-8]\./.test(process.version)) {
console.error('Crypto streams not available until v0.10');
// use the legacy, just so that we can compare them.
// Use the legacy, just so that we can compare them.
api = 'legacy';
}

Expand Down
4 changes: 2 additions & 2 deletions benchmark/crypto/hash-stream-creation.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const bench = common.createBenchmark(main, {
function main({ api, type, len, out, writes, algo }) {
if (api === 'stream' && /^v0\.[0-8]\./.test(process.version)) {
console.error('Crypto streams not available until v0.10');
// use the legacy, just so that we can compare them.
// Use the legacy, just so that we can compare them.
api = 'legacy';
}

Expand Down Expand Up @@ -54,7 +54,7 @@ function legacyWrite(algo, message, encoding, writes, len, outEnc) {
h.update(message, encoding);
var res = h.digest(outEnc);

// include buffer creation costs for older versions
// Include buffer creation costs for older versions
if (outEnc === 'buffer' && typeof res === 'string')
res = Buffer.from(res, 'binary');
}
Expand Down
2 changes: 1 addition & 1 deletion benchmark/crypto/hash-stream-throughput.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const bench = common.createBenchmark(main, {
function main({ api, type, len, algo, writes }) {
if (api === 'stream' && /^v0\.[0-8]\./.test(process.version)) {
console.error('Crypto streams not available until v0.10');
// use the legacy, just so that we can compare them.
// Use the legacy, just so that we can compare them.
api = 'legacy';
}

Expand Down
2 changes: 1 addition & 1 deletion benchmark/crypto/rsa-encrypt-decrypt-throughput.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
'use strict';
// throughput benchmark in signing and verifying
// Throughput benchmark in signing and verifying
const common = require('../common.js');
const crypto = require('crypto');
const fs = require('fs');
Expand Down
2 changes: 1 addition & 1 deletion benchmark/crypto/rsa-sign-verify-throughput.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
'use strict';
// throughput benchmark in signing and verifying
// Throughput benchmark in signing and verifying
const common = require('../common.js');
const crypto = require('crypto');
const fs = require('fs');
Expand Down
2 changes: 1 addition & 1 deletion benchmark/fs/read-stream-throughput.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// test the throughput of the fs.WriteStream class.
// Test the throughput of the fs.WriteStream class.
'use strict';

const path = require('path');
Expand Down
2 changes: 1 addition & 1 deletion benchmark/fs/write-stream-throughput.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// test the throughput of the fs.WriteStream class.
// Test the throughput of the fs.WriteStream class.
'use strict';

const path = require('path');
Expand Down
4 changes: 2 additions & 2 deletions benchmark/net/tcp-raw-c2s.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
const common = require('../common.js');
const util = require('util');

// if there are --dur=N and --len=N args, then
// If there are --dur=N and --len=N args, then
// run the function with those settings.
// if not, then queue up a bunch of child processes.
const bench = common.createBenchmark(main, {
Expand Down Expand Up @@ -36,7 +36,7 @@ function main({ dur, len, type }) {
if (err)
fail(err, 'connect');

// the meat of the benchmark is right here:
// The meat of the benchmark is right here:
bench.start();
var bytes = 0;

Expand Down
2 changes: 1 addition & 1 deletion benchmark/net/tcp-raw-pipe.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
const common = require('../common.js');
const util = require('util');

// if there are --dur=N and --len=N args, then
// If there are --dur=N and --len=N args, then
// run the function with those settings.
// if not, then queue up a bunch of child processes.
const bench = common.createBenchmark(main, {
Expand Down
2 changes: 1 addition & 1 deletion benchmark/net/tcp-raw-s2c.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ function main({ dur, len, type }) {

clientHandle.readStart();

// the meat of the benchmark is right here:
// The meat of the benchmark is right here:
bench.start();

setTimeout(() => {
Expand Down
2 changes: 1 addition & 1 deletion doc/api/child_process.md
Original file line number Diff line number Diff line change
Expand Up @@ -1070,7 +1070,7 @@ const subprocess = spawn(
);

setTimeout(() => {
subprocess.kill(); // does not terminate the node process in the shell
subprocess.kill(); // Does not terminate the node process in the shell
}, 2000);
```

Expand Down
10 changes: 5 additions & 5 deletions doc/api/domain.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ if (cluster.isMaster) {
// Anything can happen now! Be very careful!

try {
// make sure we close down within 30 seconds
// Make sure we close down within 30 seconds
const killtimer = setTimeout(() => {
process.exit(1);
}, 30000);
Expand All @@ -148,7 +148,7 @@ if (cluster.isMaster) {
res.setHeader('content-type', 'text/plain');
res.end('Oops, there was a problem!\n');
} catch (er2) {
// oh well, not much we can do at this point.
// Oh well, not much we can do at this point.
console.error(`Error sending 500! ${er2.stack}`);
}
});
Expand Down Expand Up @@ -240,13 +240,13 @@ perhaps we would like to have a separate domain to use for each request.
That is possible via explicit binding.

```js
// create a top-level domain for the server
// Create a top-level domain for the server
const domain = require('domain');
const http = require('http');
const serverDomain = domain.create();

serverDomain.run(() => {
// server is created in the scope of serverDomain
// Server is created in the scope of serverDomain
http.createServer((req, res) => {
// Req and res are also created in the scope of serverDomain
// however, we'd prefer to have a separate domain for each request.
Expand Down Expand Up @@ -373,7 +373,7 @@ const d = domain.create();

function readSomeFile(filename, cb) {
fs.readFile(filename, 'utf8', d.intercept((data) => {
// note, the first argument is never passed to the
// Note, the first argument is never passed to the
// callback since it is assumed to be the 'Error' argument
// and thus intercepted by the domain.

Expand Down
2 changes: 1 addition & 1 deletion doc/api/http.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ http.get({
hostname: 'localhost',
port: 80,
path: '/',
agent: false // create a new agent just for this one request
agent: false // Create a new agent just for this one request
}, (res) => {
// Do stuff with response
});
Expand Down
6 changes: 3 additions & 3 deletions doc/api/http2.md
Original file line number Diff line number Diff line change
Expand Up @@ -2600,7 +2600,7 @@ const server = createSecureServer(
).listen(4443);

function onRequest(req, res) {
// detects if it is a HTTPS request or HTTP/2
// Detects if it is a HTTPS request or HTTP/2
const { socket: { alpnProtocol } } = req.httpVersion === '2.0' ?
req.stream.session : req;
res.writeHead(200, { 'content-type': 'application/json' });
Expand Down Expand Up @@ -3373,9 +3373,9 @@ const obs = new PerformanceObserver((items) => {
const entry = items.getEntries()[0];
console.log(entry.entryType); // prints 'http2'
if (entry.name === 'Http2Session') {
// entry contains statistics about the Http2Session
// Entry contains statistics about the Http2Session
} else if (entry.name === 'Http2Stream') {
// entry contains statistics about the Http2Stream
// Entry contains statistics about the Http2Stream
}
});
obs.observe({ entryTypes: ['http2'] });
Expand Down
2 changes: 1 addition & 1 deletion doc/api/inspector.md
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ session.connect();

session.post('Profiler.enable', () => {
session.post('Profiler.start', () => {
// invoke business logic under measurement here...
// Invoke business logic under measurement here...

// some time later...
session.post('Profiler.stop', (err, { profile }) => {
Expand Down
2 changes: 1 addition & 1 deletion doc/api/querystring.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ Any other input values will be coerced to empty strings.

```js
querystring.stringify({ foo: 'bar', baz: ['qux', 'quux'], corge: '' });
// returns 'foo=bar&baz=qux&baz=quux&corge='
// Returns 'foo=bar&baz=qux&baz=quux&corge='

querystring.stringify({ foo: 'bar', baz: 'qux' }, ';', ':');
// returns 'foo:bar;baz:qux'
Expand Down
8 changes: 4 additions & 4 deletions doc/api/stream.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ const server = http.createServer((req, res) => {
req.on('end', () => {
try {
const data = JSON.parse(body);
// write back something interesting to the user:
// Write back something interesting to the user:
res.write(typeof data);
res.end();
} catch (er) {
Expand Down Expand Up @@ -413,7 +413,7 @@ Calling the [`stream.write()`][stream-write] method after calling
[`stream.end()`][stream-end] will raise an error.

```js
// write 'hello, ' and then end with 'world!'
// Write 'hello, ' and then end with 'world!'
const fs = require('fs');
const file = fs.createWriteStream('example.txt');
file.write('hello, ');
Expand Down Expand Up @@ -684,7 +684,7 @@ pass.unpipe(writable);

pass.on('data', (chunk) => { console.log(chunk.toString()); });
pass.write('ok'); // will not emit 'data'
pass.resume(); // must be called to make stream emit 'data'
pass.resume(); // Must be called to make stream emit 'data'
```

While `readable.readableFlowing` is `false`, data may be accumulating
Expand Down Expand Up @@ -1211,7 +1211,7 @@ function parseHeader(stream, callback) {
const remaining = split.join('\n\n');
const buf = Buffer.from(remaining, 'utf8');
stream.removeListener('error', callback);
// remove the 'readable' listener before unshifting
// Remove the 'readable' listener before unshifting
stream.removeListener('readable', onReadable);
if (buf.length)
stream.unshift(buf);
Expand Down
2 changes: 1 addition & 1 deletion doc/api/util.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ const util = require('util');

const fn1 = util.deprecate(someFunction, someMessage, 'DEP0001');
const fn2 = util.deprecate(someOtherFunction, someOtherMessage, 'DEP0001');
fn1(); // emits a deprecation warning with code DEP0001
fn1(); // Emits a deprecation warning with code DEP0001
fn2(); // Does not emit a deprecation warning because it has the same code
```

Expand Down
2 changes: 1 addition & 1 deletion lib/_stream_duplex.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ Object.defineProperty(Duplex.prototype, 'destroyed', {
return;
}

// backward compatibility, the user is explicitly
// Backward compatibility, the user is explicitly
// managing destroyed
this._readableState.destroyed = value;
this._writableState.destroyed = value;
Expand Down
22 changes: 11 additions & 11 deletions lib/_stream_readable.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ function ReadableState(options, stream, isDuplex) {
// The number of writers that are awaiting a drain event in .pipe()s
this.awaitDrain = 0;

// if true, a maybeReadMore has been scheduled
// If true, a maybeReadMore has been scheduled
this.readingMore = false;

this.decoder = null;
Expand Down Expand Up @@ -188,7 +188,7 @@ Object.defineProperty(Readable.prototype, 'destroyed', {
return;
}

// backward compatibility, the user is explicitly
// Backward compatibility, the user is explicitly
// managing destroyed
this._readableState.destroyed = value;
}
Expand Down Expand Up @@ -668,7 +668,7 @@ Readable.prototype.pipe = function(dest, pipeOpts) {
var cleanedUp = false;
function cleanup() {
debug('cleanup');
// cleanup event handlers once the pipe is broken
// Cleanup event handlers once the pipe is broken
dest.removeListener('close', onclose);
dest.removeListener('finish', onfinish);
dest.removeListener('drain', ondrain);
Expand Down Expand Up @@ -744,7 +744,7 @@ Readable.prototype.pipe = function(dest, pipeOpts) {
// tell the dest that it's being piped to
dest.emit('pipe', src);

// start the flow if it hasn't been started already.
// Start the flow if it hasn't been started already.
if (!state.flowing) {
debug('pipe resume');
src.resume();
Expand All @@ -771,13 +771,13 @@ Readable.prototype.unpipe = function(dest) {
var state = this._readableState;
var unpipeInfo = { hasUnpiped: false };

// if we're not piping anywhere, then do nothing.
// If we're not piping anywhere, then do nothing.
if (state.pipesCount === 0)
return this;

// just one destination. most common case.
// Just one destination. most common case.
if (state.pipesCount === 1) {
// passed in one, but it's not the right one.
// Passed in one, but it's not the right one.
if (dest && dest !== state.pipes)
return this;

Expand Down Expand Up @@ -823,7 +823,7 @@ Readable.prototype.unpipe = function(dest) {
return this;
};

// set up data events if they are asked for
// Set up data events if they are asked for
// Ensure readable listeners eventually get something
Readable.prototype.on = function(ev, fn) {
const res = Stream.prototype.on.call(this, ev, fn);
Expand Down Expand Up @@ -892,7 +892,7 @@ function updateReadableListening(self) {
state.readableListening = self.listenerCount('readable') > 0;

if (state.resumeScheduled && !state.paused) {
// flowing needs to be set to true now, otherwise
// Flowing needs to be set to true now, otherwise
// the upcoming resume will not flow.
state.flowing = true;

Expand All @@ -913,7 +913,7 @@ Readable.prototype.resume = function() {
var state = this._readableState;
if (!state.flowing) {
debug('resume');
// we flow only if there is no one listening
// We flow only if there is no one listening
// for readable, but we still have to call
// resume()
state.flowing = !state.readableListening;
Expand Down Expand Up @@ -983,7 +983,7 @@ Readable.prototype.wrap = function(stream) {
if (state.decoder)
chunk = state.decoder.write(chunk);

// don't skip over falsy values in objectMode
// Don't skip over falsy values in objectMode
if (state.objectMode && (chunk === null || chunk === undefined))
return;
else if (!state.objectMode && (!chunk || !chunk.length))
Expand Down
Loading

0 comments on commit d66cb4a

Please sign in to comment.