diff --git a/.eslintrc.js b/.eslintrc.js index 23ddc3c95cd39d..6dda76cb4ea985 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -58,6 +58,18 @@ module.exports = { 'arrow-spacing': ['error', { before: true, after: true }], 'block-spacing': 'error', 'brace-style': ['error', '1tbs', { allowSingleLine: true }], + 'capitalized-comments': ['error', 'always', { + line: { + // Ignore all lines that have less characters than 62 and all lines that + // start with something that looks like a variable name or code. + ignorePattern: '^.{0,62}$|^ [a-z]+ ?[0-9A-Z_.(/=:-]', + ignoreInlineComments: true, + ignoreConsecutiveComments: true + }, + block: { + ignorePattern: '.*' + } + }], 'comma-dangle': ['error', 'only-multiline'], 'comma-spacing': 'error', 'comma-style': 'error', diff --git a/benchmark/_cli.js b/benchmark/_cli.js index 4d92b05b1b82b4..0c39c0b1931f48 100644 --- a/benchmark/_cli.js +++ b/benchmark/_cli.js @@ -49,7 +49,7 @@ function CLI(usage, settings) { this.optional[currentOptional] = true; mode = 'both'; } else { - // expect the next value to be option related (either -- or the value) + // Expect the next value to be option related (either -- or the value) mode = 'option'; } } else if (mode === 'option') { diff --git a/benchmark/child_process/child-process-exec-stdout.js b/benchmark/child_process/child-process-exec-stdout.js index 88c02533f605c2..a1dc4aa04c72a9 100644 --- a/benchmark/child_process/child-process-exec-stdout.js +++ b/benchmark/child_process/child-process-exec-stdout.js @@ -31,7 +31,7 @@ function childProcessExecStdout({ dur, len }) { try { execSync(`taskkill /f /t /pid ${child.pid}`); } catch { - // this is a best effort kill. stderr is piped to parent for tracing. + // This is a best effort kill. stderr is piped to parent for tracing. } } else { child.kill(); diff --git a/benchmark/common.js b/benchmark/common.js index d5e0494c16e826..521a145997a8a4 100644 --- a/benchmark/common.js +++ b/benchmark/common.js @@ -146,7 +146,7 @@ Benchmark.prototype._run = function() { (function recursive(queueIndex) { const config = self.queue[queueIndex]; - // set NODE_RUN_BENCHMARK_FN to indicate that the child shouldn't construct + // Set NODE_RUN_BENCHMARK_FN to indicate that the child shouldn't construct // a configuration queue, but just execute the benchmark function. const childEnv = Object.assign({}, process.env); childEnv.NODE_RUN_BENCHMARK_FN = ''; @@ -187,7 +187,7 @@ Benchmark.prototype.start = function() { }; Benchmark.prototype.end = function(operations) { - // get elapsed time now and do error checking later for accuracy. + // Get elapsed time now and do error checking later for accuracy. const elapsed = process.hrtime(this._time); if (!this._started) { diff --git a/benchmark/crypto/cipher-stream.js b/benchmark/crypto/cipher-stream.js index 9f986dfb36b60d..c9989d32dcd20a 100644 --- a/benchmark/crypto/cipher-stream.js +++ b/benchmark/crypto/cipher-stream.js @@ -58,7 +58,7 @@ function main({ api, cipher, type, len, writes }) { const fn = api === 'stream' ? streamWrite : legacyWrite; - // write data as fast as possible to alice, and have bob decrypt. + // Write data as fast as possible to alice, and have bob decrypt. // use old API for comparison to v0.8 bench.start(); fn(alice_cipher, bob_cipher, message, encoding, writes); diff --git a/benchmark/dgram/array-vs-concat.js b/benchmark/dgram/array-vs-concat.js index a7843a9c7f7c28..c73c9538589540 100644 --- a/benchmark/dgram/array-vs-concat.js +++ b/benchmark/dgram/array-vs-concat.js @@ -1,4 +1,4 @@ -// test UDP send throughput with the multi buffer API against Buffer.concat +// Test UDP send throughput with the multi buffer API against Buffer.concat 'use strict'; const common = require('../common.js'); diff --git a/benchmark/dgram/offset-length.js b/benchmark/dgram/offset-length.js index 8a2df9ac67c1b6..7c78765cee0d09 100644 --- a/benchmark/dgram/offset-length.js +++ b/benchmark/dgram/offset-length.js @@ -1,4 +1,4 @@ -// test UDP send/recv throughput with the "old" offset/length API +// Test UDP send/recv throughput with the "old" offset/length API 'use strict'; const common = require('../common.js'); diff --git a/benchmark/napi/function_call/index.js b/benchmark/napi/function_call/index.js index 59063e500f7a84..e7d9fe46e54636 100644 --- a/benchmark/napi/function_call/index.js +++ b/benchmark/napi/function_call/index.js @@ -7,7 +7,7 @@ const assert = require('assert'); const common = require('../../common.js'); -// this fails when we try to open with a different version of node, +// This fails when we try to open with a different version of node, // which is quite common for benchmarks. so in that case, just // abort quietly. diff --git a/benchmark/net/net-wrap-js-stream-passthrough.js b/benchmark/net/net-wrap-js-stream-passthrough.js index c4d11fa56c7411..0e76281b25e927 100644 --- a/benchmark/net/net-wrap-js-stream-passthrough.js +++ b/benchmark/net/net-wrap-js-stream-passthrough.js @@ -1,4 +1,4 @@ -// test the speed of .pipe() with JSStream wrapping for PassThrough streams +// Test the speed of .pipe() with JSStream wrapping for PassThrough streams 'use strict'; const common = require('../common.js'); diff --git a/doc/api/async_hooks.md b/doc/api/async_hooks.md index ad7a94736ff540..587a74c3d06caa 100644 --- a/doc/api/async_hooks.md +++ b/doc/api/async_hooks.md @@ -61,12 +61,12 @@ asyncHook.disable(); // resource referenced by "asyncId" may not have been populated. function init(asyncId, type, triggerAsyncId, resource) { } -// before is called just before the resource's callback is called. It can be +// Before is called just before the resource's callback is called. It can be // called 0-N times for handles (e.g. TCPWrap), and will be called exactly 1 // time for requests (e.g. FSReqCallback). function before(asyncId) { } -// after is called just after the resource's callback has finished. +// After is called just after the resource's callback has finished. function after(asyncId) { } // destroy is called when an AsyncWrap instance is destroyed. @@ -159,7 +159,7 @@ const fs = require('fs'); const util = require('util'); function debug(...args) { - // use a function like this one when debugging inside an AsyncHooks callback + // Use a function like this one when debugging inside an AsyncHooks callback fs.writeFileSync('log.out', `${util.format(...args)}\n`, { flag: 'a' }); } ``` diff --git a/doc/api/crypto.md b/doc/api/crypto.md index 3e1de25f750feb..736ac360c903d7 100644 --- a/doc/api/crypto.md +++ b/doc/api/crypto.md @@ -772,7 +772,7 @@ const uncompressedKey = ECDH.convertKey(compressedKey, 'hex', 'uncompressed'); -// the converted key and the uncompressed public key should be the same +// The converted key and the uncompressed public key should be the same console.log(uncompressedKey === ecdh.getPublicKey('hex')); ``` diff --git a/doc/api/domain.md b/doc/api/domain.md index eec763600e228f..3a1027f07b8afa 100644 --- a/doc/api/domain.md +++ b/doc/api/domain.md @@ -143,7 +143,7 @@ if (cluster.isMaster) { // a new worker. cluster.worker.disconnect(); - // try to send an error to the request that triggered the problem + // Try to send an error to the request that triggered the problem res.statusCode = 500; res.setHeader('content-type', 'text/plain'); res.end('Oops, there was a problem!\n'); diff --git a/doc/api/errors.md b/doc/api/errors.md index 1c16e05de84ac2..05ecad70214fb4 100644 --- a/doc/api/errors.md +++ b/doc/api/errors.md @@ -371,7 +371,7 @@ range, or outside the set of options for a given function parameter. ```js require('net').connect(-1); -// throws "RangeError: "port" option should be >= 0 and < 65536: -1" +// Throws "RangeError: "port" option should be >= 0 and < 65536: -1" ``` Node.js will generate and throw `RangeError` instances *immediately* as a form @@ -388,7 +388,7 @@ will do so. ```js doesNotExist; -// throws ReferenceError, doesNotExist is not a variable in this program. +// Throws ReferenceError, doesNotExist is not a variable in this program. ``` Unless an application is dynamically generating and running code, diff --git a/doc/api/events.md b/doc/api/events.md index aafdbcf735bee5..4fcaeb3211c4f2 100644 --- a/doc/api/events.md +++ b/doc/api/events.md @@ -638,14 +638,14 @@ emitter.once('log', () => console.log('log once')); const listeners = emitter.rawListeners('log'); const logFnWrapper = listeners[0]; -// logs "log once" to the console and does not unbind the `once` event +// Logs "log once" to the console and does not unbind the `once` event logFnWrapper.listener(); // logs "log once" to the console and removes the listener logFnWrapper(); emitter.on('log', () => console.log('log persistently')); -// will return a new Array with a single function bound by `.on()` above +// Will return a new Array with a single function bound by `.on()` above const newListeners = emitter.rawListeners('log'); // logs "log persistently" twice diff --git a/doc/api/fs.md b/doc/api/fs.md index fcd42fd19af1cd..01d537d8e3b40d 100644 --- a/doc/api/fs.md +++ b/doc/api/fs.md @@ -1926,7 +1926,7 @@ console.log(fs.readFileSync('temp.txt', 'utf8')); // get the file descriptor of the file to be truncated const fd = fs.openSync('temp.txt', 'r+'); -// truncate the file to 10 bytes, whereas the actual size is 7 bytes +// Truncate the file to 10 bytes, whereas the actual size is 7 bytes fs.ftruncate(fd, 10, (err) => { assert.ifError(err); console.log(fs.readFileSync('temp.txt')); diff --git a/doc/api/modules.md b/doc/api/modules.md index 28a13fb36dc4b9..5292d2389760bd 100644 --- a/doc/api/modules.md +++ b/doc/api/modules.md @@ -49,7 +49,7 @@ console.log(`The area of mySquare is ${mySquare.area()}`); The `square` module is defined in `square.js`: ```js -// assigning to exports will not modify module, must use module.exports +// Assigning to exports will not modify module, must use module.exports module.exports = class Square { constructor(width) { this.width = width; diff --git a/doc/api/process.md b/doc/api/process.md index 64d93a87603ef6..818bb6ed4ab73c 100644 --- a/doc/api/process.md +++ b/doc/api/process.md @@ -286,7 +286,7 @@ The listener function is called with the following arguments: ```js process.on('unhandledRejection', (reason, p) => { console.log('Unhandled Rejection at:', p, 'reason:', reason); - // application specific logging, throwing an error, or other logic here + // Application specific logging, throwing an error, or other logic here }); somePromise.then((res) => { diff --git a/doc/api/stream.md b/doc/api/stream.md index 5441cb03724d05..c1f23adae5a30b 100644 --- a/doc/api/stream.md +++ b/doc/api/stream.md @@ -131,7 +131,7 @@ const server = http.createServer((req, res) => { body += chunk; }); - // the 'end' event indicates that the entire body has been received + // The 'end' event indicates that the entire body has been received req.on('end', () => { try { const data = JSON.parse(body); diff --git a/doc/api/util.md b/doc/api/util.md index 97fcdf4e2651b5..ce8a59ac174e99 100644 --- a/doc/api/util.md +++ b/doc/api/util.md @@ -159,7 +159,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 -fn2(); // does not emit a deprecation warning because it has the same code +fn2(); // Does not emit a deprecation warning because it has the same code ``` If either the `--no-deprecation` or `--no-warnings` command line flags are diff --git a/doc/api/worker_threads.md b/doc/api/worker_threads.md index 0fc133376d35d4..bc9f18402fcfaf 100644 --- a/doc/api/worker_threads.md +++ b/doc/api/worker_threads.md @@ -109,7 +109,7 @@ const { MessageChannel } = require('worker_threads'); const { port1, port2 } = new MessageChannel(); port1.on('message', (message) => console.log('received', message)); port2.postMessage({ foo: 'bar' }); -// prints: received { foo: 'bar' } from the `port1.on('message')` listener +// Prints: received { foo: 'bar' } from the `port1.on('message')` listener ``` ## Class: MessagePort diff --git a/lib/_http_agent.js b/lib/_http_agent.js index 97c5ab604ff821..e3d307133864f4 100644 --- a/lib/_http_agent.js +++ b/lib/_http_agent.js @@ -50,7 +50,7 @@ function Agent(options) { this.options = util._extend({}, options); - // don't confuse net and make it think that we're connecting to a pipe + // Don't confuse net and make it think that we're connecting to a pipe this.options.path = null; this.requests = {}; this.sockets = {}; diff --git a/lib/_http_outgoing.js b/lib/_http_outgoing.js index 6741b0d61ea99d..7395a02f331af0 100644 --- a/lib/_http_outgoing.js +++ b/lib/_http_outgoing.js @@ -387,7 +387,7 @@ function _storeHeader(firstLine, headers) { this._header = header + CRLF; this._headerSent = false; - // wait until the first body chunk, or close(), is sent to flush, + // Wait until the first body chunk, or close(), is sent to flush, // UNLESS we're sending Expect: 100-continue. if (state.expect) this._send(''); } diff --git a/lib/_http_server.js b/lib/_http_server.js index d54dcba7fcf55b..1dc44a4ce4c8b3 100644 --- a/lib/_http_server.js +++ b/lib/_http_server.js @@ -261,7 +261,7 @@ function writeHead(statusCode, reason, obj) { this._hasBody = false; } - // don't keep alive connections where the client expects 100 Continue + // Don't keep alive connections where the client expects 100 Continue // but we sent a final status; they may put extra bytes on the wire. if (this._expect_continue && !this._sent100) { this.shouldKeepAlive = false; diff --git a/lib/_stream_readable.js b/lib/_stream_readable.js index 47dbae31b5f2c1..23a10209bde3f0 100644 --- a/lib/_stream_readable.js +++ b/lib/_stream_readable.js @@ -85,7 +85,7 @@ function ReadableState(options, stream, isDuplex) { if (isDuplex) this.objectMode = this.objectMode || !!options.readableObjectMode; - // the point at which it stops calling _read() to fill the buffer + // The point at which it stops calling _read() to fill the buffer // Note: 0 is a valid value, means "don't call _read preemptively ever" this.highWaterMark = getHighWaterMark(this, options, 'readableHighWaterMark', isDuplex); @@ -102,7 +102,7 @@ function ReadableState(options, stream, isDuplex) { this.endEmitted = false; this.reading = false; - // a flag to be able to tell if the event 'readable'/'data' is emitted + // A flag to be able to tell if the event 'readable'/'data' is emitted // immediately, or on a later tick. We set this to true at first, because // any actions that shouldn't happen until "later" should generally also // not happen before the first read call. @@ -130,7 +130,7 @@ function ReadableState(options, stream, isDuplex) { // Everything else in the universe uses 'utf8', though. this.defaultEncoding = options.defaultEncoding || 'utf8'; - // the number of writers that are awaiting a drain event in .pipe()s + // The number of writers that are awaiting a drain event in .pipe()s this.awaitDrain = 0; // if true, a maybeReadMore has been scheduled @@ -373,7 +373,7 @@ function howMuchToRead(n, state) { return state.length; } -// you can override either this method, or the async _read(n) below. +// You can override either this method, or the async _read(n) below. Readable.prototype.read = function(n) { debug('read', n); n = parseInt(n, 10); @@ -435,13 +435,13 @@ Readable.prototype.read = function(n) { var doRead = state.needReadable; debug('need readable', doRead); - // if we currently have less than the highWaterMark, then also read some + // If we currently have less than the highWaterMark, then also read some if (state.length === 0 || state.length - n < state.highWaterMark) { doRead = true; debug('length less than watermark', doRead); } - // however, if we've ended, then there's no point, and if we're already + // However, if we've ended, then there's no point, and if we're already // reading, then it's unnecessary. if (state.ended || state.reading) { doRead = false; @@ -450,7 +450,7 @@ Readable.prototype.read = function(n) { debug('do read'); state.reading = true; state.sync = true; - // if the length is currently zero, then we *need* a readable event. + // If the length is currently zero, then we *need* a readable event. if (state.length === 0) state.needReadable = true; // call internal read method @@ -553,7 +553,7 @@ function emitReadable_(stream) { } -// at this point, the user has presumably seen the 'readable' event, +// At this point, the user has presumably seen the 'readable' event, // and called read() to consume some data. that may have triggered // in turn another _read(n) call, in which case reading = true if // it's in progress. @@ -581,7 +581,7 @@ function maybeReadMore_(stream, state) { state.readingMore = false; } -// abstract method. to be overridden in specific implementation classes. +// Abstract method. to be overridden in specific implementation classes. // call cb(er, data) where data is <= n in length. // for virtual (non-string, non-buffer) streams, "length" is somewhat // arbitrary, and perhaps not very meaningful. diff --git a/lib/_stream_transform.js b/lib/_stream_transform.js index 679f79b80dfb35..af7f5347a52110 100644 --- a/lib/_stream_transform.js +++ b/lib/_stream_transform.js @@ -116,10 +116,10 @@ function Transform(options) { writeencoding: null }; - // start out asking for a readable event once data is transformed. + // Start out asking for a readable event once data is transformed. this._readableState.needReadable = true; - // we have implemented the _read method, and done the other things + // We have implemented the _read method, and done the other things // that Readable wants before the first _read call, so unset the // sync guard flag. this._readableState.sync = false; diff --git a/lib/_stream_writable.js b/lib/_stream_writable.js index 022dcffdd78e28..0b013a01dd6196 100644 --- a/lib/_stream_writable.js +++ b/lib/_stream_writable.js @@ -90,7 +90,7 @@ function WritableState(options, stream, isDuplex) { // has it been destroyed this.destroyed = false; - // should we decode strings into buffers before passing to _write? + // Should we decode strings into buffers before passing to _write? // this is here so that some node-core streams can optimize string // handling at a lower level. var noDecode = options.decodeStrings === false; @@ -112,13 +112,13 @@ function WritableState(options, stream, isDuplex) { // when true all writes will be buffered until .uncork() call this.corked = 0; - // a flag to be able to tell if the onwrite cb is called immediately, + // A flag to be able to tell if the onwrite cb is called immediately, // or on a later tick. We set this to true at first, because any // actions that shouldn't happen until "later" should generally also // not happen before the first write call. this.sync = true; - // a flag to know if we're processing previously buffered items, which + // A flag to know if we're processing previously buffered items, which // may call the _write() callback in the same tick, so that we don't // end up in an overlapped onwrite situation. this.bufferProcessing = false; @@ -126,7 +126,7 @@ function WritableState(options, stream, isDuplex) { // the callback that's passed to _write(chunk,cb) this.onwrite = onwrite.bind(undefined, stream); - // the callback that the user supplies to write(chunk,encoding,cb) + // The callback that the user supplies to write(chunk,encoding,cb) this.writecb = null; // the amount that is being written when _write is called. @@ -139,7 +139,7 @@ function WritableState(options, stream, isDuplex) { // this must be 0 before 'finish' can be emitted this.pendingcb = 0; - // emit prefinish if the only thing we're waiting for is _write cbs + // Emit prefinish if the only thing we're waiting for is _write cbs // This is relevant for synchronous Transform streams this.prefinished = false; @@ -376,7 +376,7 @@ function writeOrBuffer(stream, state, isBuf, chunk, encoding, cb) { state.length += len; var ret = state.length < state.highWaterMark; - // we must ensure that previous needDrain will not be reset to false. + // We must ensure that previous needDrain will not be reset to false. if (!ret) state.needDrain = true; diff --git a/lib/buffer.js b/lib/buffer.js index ac5e19c40819c1..b032736f509e5c 100644 --- a/lib/buffer.js +++ b/lib/buffer.js @@ -916,7 +916,7 @@ Buffer.prototype.write = function write(string, offset, length, encoding) { if (string.length > 0 && (length < 0 || offset < 0)) throw new ERR_BUFFER_OUT_OF_BOUNDS(); } else { - // if someone is still calling the obsolete form of write(), tell them. + // If someone is still calling the obsolete form of write(), tell them. // we don't want eg buf.write("foo", "utf8", 10) to silently turn into // buf.write("foo", "utf8"), so we can't ignore extra args throw new ERR_NO_LONGER_SUPPORTED( diff --git a/lib/console.js b/lib/console.js index 29d551549ddfa9..570515aefe0b62 100644 --- a/lib/console.js +++ b/lib/console.js @@ -171,7 +171,7 @@ function write(ignoreErrors, stream, string, errorhandler, groupIndent) { stream.write(string, errorhandler); } catch (e) { - // console is a debugging utility, so it swallowing errors is not desirable + // Console is a debugging utility, so it swallowing errors is not desirable // even in edge cases such as low stack space. if (isStackOverflowError(e)) throw e; diff --git a/lib/dgram.js b/lib/dgram.js index 55662313d640cd..27c38191735f38 100644 --- a/lib/dgram.js +++ b/lib/dgram.js @@ -312,7 +312,7 @@ Socket.prototype.bind = function(port_, address_ /* , callback */) { }; -// thin wrapper around `send`, here for compatibility with dgram_legacy.js +// Thin wrapper around `send`, here for compatibility with dgram_legacy.js Socket.prototype.sendto = function(buffer, offset, length, diff --git a/lib/domain.js b/lib/domain.js index e8ae3ff1003486..899978cf7069d2 100644 --- a/lib/domain.js +++ b/lib/domain.js @@ -35,7 +35,7 @@ const { } = require('internal/errors').codes; const { createHook } = require('async_hooks'); -// overwrite process.domain with a getter/setter that will allow for more +// Overwrite process.domain with a getter/setter that will allow for more // effective optimizations var _domain = [null]; Object.defineProperty(process, 'domain', { diff --git a/lib/fs.js b/lib/fs.js index d8582786f174b0..5a951d1f767640 100644 --- a/lib/fs.js +++ b/lib/fs.js @@ -1421,7 +1421,7 @@ function realpathSync(p, options) { let pos; // the partial path so far, including a trailing slash if any let current; - // the partial path without a trailing slash (except when pointing at a root) + // The partial path without a trailing slash (except when pointing at a root) let base; // the partial path scanned in the previous round, with slash let previous; @@ -1438,7 +1438,7 @@ function realpathSync(p, options) { knownHard[base] = true; } - // walk down the path, swapping out linked path parts for their real + // Walk down the path, swapping out linked path parts for their real // values // NB: p.length changes. while (pos < p.length) { @@ -1561,7 +1561,7 @@ function realpath(p, options, callback) { let pos; // the partial path so far, including a trailing slash if any let current; - // the partial path without a trailing slash (except when pointing at a root) + // The partial path without a trailing slash (except when pointing at a root) let base; // the partial path scanned in the previous round, with slash let previous; @@ -1580,7 +1580,7 @@ function realpath(p, options, callback) { process.nextTick(LOOP); } - // walk down the path, swapping out linked path parts for their real + // Walk down the path, swapping out linked path parts for their real // values function LOOP() { // stop if scanned past end of path diff --git a/lib/internal/child_process.js b/lib/internal/child_process.js index 2562a76cd9be0d..b6f9ca96296adb 100644 --- a/lib/internal/child_process.js +++ b/lib/internal/child_process.js @@ -62,7 +62,7 @@ let HTTPParser; const MAX_HANDLE_RETRANSMISSIONS = 3; -// this object contain function to convert TCP objects to native handle objects +// This object contain function to convert TCP objects to native handle objects // and back again. const handleConversion = { 'net.Native': { @@ -117,7 +117,7 @@ const handleConversion = { var handle = socket._handle; - // remove handle from socket object, it will be closed when the socket + // Remove handle from socket object, it will be closed when the socket // will be sent if (!options.keepOpen) { handle.onread = nop; @@ -166,7 +166,7 @@ const handleConversion = { writable: true }); - // if the socket was created by net.Server we will track the socket + // If the socket was created by net.Server we will track the socket if (message.key) { // add socket to connections list @@ -663,7 +663,7 @@ function setupChannel(target, channel) { // package messages with a handle object if (handle) { - // this message will be handled by an internalMessage event handler + // This message will be handled by an internalMessage event handler message = { cmd: 'NODE_HANDLE', type: null, @@ -768,7 +768,7 @@ function setupChannel(target, channel) { return channel.writeQueueSize < (65536 * 2); }; - // connected will be set to false immediately when a disconnect() is + // Connected will be set to false immediately when a disconnect() is // requested, even though the channel might still be alive internally to // process queued messages. The three states are distinguished as follows: // - disconnect() never requested: channel is not null and connected diff --git a/lib/internal/console/constructor.js b/lib/internal/console/constructor.js new file mode 100644 index 00000000000000..d3c5ed74367b8a --- /dev/null +++ b/lib/internal/console/constructor.js @@ -0,0 +1,518 @@ +'use strict'; + +// The Console constructor is not actually used to construct the global +// console. It's exported for backwards compatibility. + +const { trace } = internalBinding('trace_events'); +const { + isStackOverflowError, + codes: { + ERR_CONSOLE_WRITABLE_STREAM, + ERR_INVALID_ARG_TYPE, + ERR_INVALID_ARG_VALUE, + }, +} = require('internal/errors'); +const { previewEntries } = internalBinding('util'); +const { Buffer: { isBuffer } } = require('buffer'); +const util = require('util'); +const { + isTypedArray, isSet, isMap, isSetIterator, isMapIterator, +} = util.types; +const kCounts = Symbol('counts'); + +const kTraceConsoleCategory = 'node,node.console'; +const kTraceCount = 'C'.charCodeAt(0); +const kTraceBegin = 'b'.charCodeAt(0); +const kTraceEnd = 'e'.charCodeAt(0); +const kTraceInstant = 'n'.charCodeAt(0); + +const { + keys: ObjectKeys, + values: ObjectValues, +} = Object; +const hasOwnProperty = Function.call.bind(Object.prototype.hasOwnProperty); + +const { + isArray: ArrayIsArray, + from: ArrayFrom, +} = Array; + +// Lazy loaded for startup performance. +let cliTable; + +// Track amount of indentation required via `console.group()`. +const kGroupIndent = Symbol('kGroupIndent'); +const kFormatForStderr = Symbol('kFormatForStderr'); +const kFormatForStdout = Symbol('kFormatForStdout'); +const kGetInspectOptions = Symbol('kGetInspectOptions'); +const kColorMode = Symbol('kColorMode'); +const kIsConsole = Symbol('kIsConsole'); +const kWriteToConsole = Symbol('kWriteToConsole'); +const kBindProperties = Symbol('kBindProperties'); +const kBindStreamsEager = Symbol('kBindStreamsEager'); +const kBindStreamsLazy = Symbol('kBindStreamsLazy'); +const kUseStdout = Symbol('kUseStdout'); +const kUseStderr = Symbol('kUseStderr'); + +function Console(options /* or: stdout, stderr, ignoreErrors = true */) { + // We have to test new.target here to see if this function is called + // with new, because we need to define a custom instanceof to accommodate + // the global console. + if (!new.target) { + return new Console(...arguments); + } + + if (!options || typeof options.write === 'function') { + options = { + stdout: options, + stderr: arguments[1], + ignoreErrors: arguments[2] + }; + } + + const { + stdout, + stderr = stdout, + ignoreErrors = true, + colorMode = 'auto' + } = options; + + if (!stdout || typeof stdout.write !== 'function') { + throw new ERR_CONSOLE_WRITABLE_STREAM('stdout'); + } + if (!stderr || typeof stderr.write !== 'function') { + throw new ERR_CONSOLE_WRITABLE_STREAM('stderr'); + } + + if (typeof colorMode !== 'boolean' && colorMode !== 'auto') + throw new ERR_INVALID_ARG_VALUE('colorMode', colorMode); + + // bind the prototype functions to this Console instance + var keys = Object.keys(Console.prototype); + for (var v = 0; v < keys.length; v++) { + var k = keys[v]; + // We have to bind the methods grabbed from the instance instead of from + // the prototype so that users extending the Console can override them + // from the prototype chain of the subclass. + this[k] = this[k].bind(this); + } + + this[kBindStreamsEager](stdout, stderr); + this[kBindProperties](ignoreErrors, colorMode); +} + +const consolePropAttributes = { + writable: true, + enumerable: false, + configurable: true +}; + +// Fixup global.console instanceof global.console.Console +Object.defineProperty(Console, Symbol.hasInstance, { + value(instance) { + return instance[kIsConsole]; + } +}); + +// Eager version for the Console constructor +Console.prototype[kBindStreamsEager] = function(stdout, stderr) { + Object.defineProperties(this, { + '_stdout': { ...consolePropAttributes, value: stdout }, + '_stderr': { ...consolePropAttributes, value: stderr } + }); +}; + +// Lazily load the stdout and stderr from an object so we don't +// create the stdio streams when they are not even accessed +Console.prototype[kBindStreamsLazy] = function(object) { + let stdout; + let stderr; + Object.defineProperties(this, { + '_stdout': { + enumerable: false, + configurable: true, + get() { + if (!stdout) stdout = object.stdout; + return stdout; + }, + set(value) { stdout = value; } + }, + '_stderr': { + enumerable: false, + configurable: true, + get() { + if (!stderr) { stderr = object.stderr; } + return stderr; + }, + set(value) { stderr = value; } + } + }); +}; + +Console.prototype[kBindProperties] = function(ignoreErrors, colorMode) { + Object.defineProperties(this, { + '_stdoutErrorHandler': { + ...consolePropAttributes, + value: createWriteErrorHandler(this, kUseStdout) + }, + '_stderrErrorHandler': { + ...consolePropAttributes, + value: createWriteErrorHandler(this, kUseStderr) + }, + '_ignoreErrors': { + ...consolePropAttributes, + value: Boolean(ignoreErrors) + }, + '_times': { ...consolePropAttributes, value: new Map() } + }); + + // TODO(joyeecheung): use consolePropAttributes for these + // Corresponds to https://console.spec.whatwg.org/#count-map + this[kCounts] = new Map(); + this[kColorMode] = colorMode; + this[kIsConsole] = true; + this[kGroupIndent] = ''; +}; + +// Make a function that can serve as the callback passed to `stream.write()`. +function createWriteErrorHandler(instance, streamSymbol) { + return (err) => { + // This conditional evaluates to true if and only if there was an error + // that was not already emitted (which happens when the _write callback + // is invoked asynchronously). + const stream = streamSymbol === kUseStdout ? + instance._stdout : instance._stderr; + if (err !== null && !stream._writableState.errorEmitted) { + // If there was an error, it will be emitted on `stream` as + // an `error` event. Adding a `once` listener will keep that error + // from becoming an uncaught exception, but since the handler is + // removed after the event, non-console.* writes won't be affected. + // we are only adding noop if there is no one else listening for 'error' + if (stream.listenerCount('error') === 0) { + stream.on('error', noop); + } + } + }; +} + +Console.prototype[kWriteToConsole] = function(streamSymbol, string) { + const ignoreErrors = this._ignoreErrors; + const groupIndent = this[kGroupIndent]; + + const useStdout = streamSymbol === kUseStdout; + const stream = useStdout ? this._stdout : this._stderr; + const errorHandler = useStdout ? + this._stdoutErrorHandler : this._stderrErrorHandler; + + if (groupIndent.length !== 0) { + if (string.indexOf('\n') !== -1) { + string = string.replace(/\n/g, `\n${groupIndent}`); + } + string = groupIndent + string; + } + string += '\n'; + + if (ignoreErrors === false) return stream.write(string); + + // There may be an error occurring synchronously (e.g. for files or TTYs + // on POSIX systems) or asynchronously (e.g. pipes on POSIX systems), so + // handle both situations. + try { + // Add and later remove a noop error handler to catch synchronous errors. + stream.once('error', noop); + + stream.write(string, errorHandler); + } catch (e) { + // Console is a debugging utility, so it swallowing errors is not desirable + // even in edge cases such as low stack space. + if (isStackOverflowError(e)) + throw e; + // Sorry, there's no proper way to pass along the error here. + } finally { + stream.removeListener('error', noop); + } +}; + +const kColorInspectOptions = { colors: true }; +const kNoColorInspectOptions = {}; +Console.prototype[kGetInspectOptions] = function(stream) { + let color = this[kColorMode]; + if (color === 'auto') { + color = stream.isTTY && ( + typeof stream.getColorDepth === 'function' ? + stream.getColorDepth() > 2 : true); + } + + return color ? kColorInspectOptions : kNoColorInspectOptions; +}; + +Console.prototype[kFormatForStdout] = function(args) { + const opts = this[kGetInspectOptions](this._stdout); + return util.formatWithOptions(opts, ...args); +}; + +Console.prototype[kFormatForStderr] = function(args) { + const opts = this[kGetInspectOptions](this._stderr); + return util.formatWithOptions(opts, ...args); +}; + +Console.prototype.log = function log(...args) { + this[kWriteToConsole](kUseStdout, this[kFormatForStdout](args)); +}; + +Console.prototype.debug = Console.prototype.log; +Console.prototype.info = Console.prototype.log; +Console.prototype.dirxml = Console.prototype.log; + +Console.prototype.warn = function warn(...args) { + this[kWriteToConsole](kUseStderr, this[kFormatForStderr](args)); +}; + +Console.prototype.error = Console.prototype.warn; + +Console.prototype.dir = function dir(object, options) { + options = Object.assign({ + customInspect: false + }, this[kGetInspectOptions](this._stdout), options); + this[kWriteToConsole](kUseStdout, util.inspect(object, options)); +}; + +Console.prototype.time = function time(label = 'default') { + // Coerces everything other than Symbol to a string + label = `${label}`; + if (this._times.has(label)) { + process.emitWarning(`Label '${label}' already exists for console.time()`); + return; + } + trace(kTraceBegin, kTraceConsoleCategory, `time::${label}`, 0); + this._times.set(label, process.hrtime()); +}; + +Console.prototype.timeEnd = function timeEnd(label = 'default') { + // Coerces everything other than Symbol to a string + label = `${label}`; + const hasWarned = timeLogImpl(this, 'timeEnd', label); + trace(kTraceEnd, kTraceConsoleCategory, `time::${label}`, 0); + if (!hasWarned) { + this._times.delete(label); + } +}; + +Console.prototype.timeLog = function timeLog(label = 'default', ...data) { + // Coerces everything other than Symbol to a string + label = `${label}`; + timeLogImpl(this, 'timeLog', label, data); + trace(kTraceInstant, kTraceConsoleCategory, `time::${label}`, 0); +}; + +// Returns true if label was not found +function timeLogImpl(self, name, label, data) { + const time = self._times.get(label); + if (!time) { + process.emitWarning(`No such label '${label}' for console.${name}()`); + return true; + } + const duration = process.hrtime(time); + const ms = duration[0] * 1000 + duration[1] / 1e6; + if (data === undefined) { + self.log('%s: %sms', label, ms.toFixed(3)); + } else { + self.log('%s: %sms', label, ms.toFixed(3), ...data); + } + return false; +} + +Console.prototype.trace = function trace(...args) { + const err = { + name: 'Trace', + message: this[kFormatForStderr](args) + }; + Error.captureStackTrace(err, trace); + this.error(err.stack); +}; + +Console.prototype.assert = function assert(expression, ...args) { + if (!expression) { + args[0] = `Assertion failed${args.length === 0 ? '' : `: ${args[0]}`}`; + this.warn(...args); // the arguments will be formatted in warn() again + } +}; + +// Defined by: https://console.spec.whatwg.org/#clear +Console.prototype.clear = function clear() { + // It only makes sense to clear if _stdout is a TTY. + // Otherwise, do nothing. + if (this._stdout.isTTY) { + // The require is here intentionally to avoid readline being + // required too early when console is first loaded. + const { cursorTo, clearScreenDown } = require('readline'); + cursorTo(this._stdout, 0, 0); + clearScreenDown(this._stdout); + } +}; + +// Defined by: https://console.spec.whatwg.org/#count +Console.prototype.count = function count(label = 'default') { + // Ensures that label is a string, and only things that can be + // coerced to strings. e.g. Symbol is not allowed + label = `${label}`; + const counts = this[kCounts]; + let count = counts.get(label); + if (count === undefined) + count = 1; + else + count++; + counts.set(label, count); + trace(kTraceCount, kTraceConsoleCategory, `count::${label}`, 0, count); + this.log(`${label}: ${count}`); +}; + +// Defined by: https://console.spec.whatwg.org/#countreset +Console.prototype.countReset = function countReset(label = 'default') { + const counts = this[kCounts]; + if (!counts.has(label)) { + process.emitWarning(`Count for '${label}' does not exist`); + return; + } + trace(kTraceCount, kTraceConsoleCategory, `count::${label}`, 0, 0); + counts.delete(`${label}`); +}; + +Console.prototype.group = function group(...data) { + if (data.length > 0) { + this.log(...data); + } + this[kGroupIndent] += ' '; +}; +Console.prototype.groupCollapsed = Console.prototype.group; + +Console.prototype.groupEnd = function groupEnd() { + this[kGroupIndent] = + this[kGroupIndent].slice(0, this[kGroupIndent].length - 2); +}; + +const keyKey = 'Key'; +const valuesKey = 'Values'; +const indexKey = '(index)'; +const iterKey = '(iteration index)'; + +const isArray = (v) => ArrayIsArray(v) || isTypedArray(v) || isBuffer(v); + +// https://console.spec.whatwg.org/#table +Console.prototype.table = function(tabularData, properties) { + if (properties !== undefined && !ArrayIsArray(properties)) + throw new ERR_INVALID_ARG_TYPE('properties', 'Array', properties); + + if (tabularData === null || typeof tabularData !== 'object') + return this.log(tabularData); + + if (cliTable === undefined) cliTable = require('internal/cli_table'); + const final = (k, v) => this.log(cliTable(k, v)); + + const inspect = (v) => { + const opt = { depth: 0, maxArrayLength: 3 }; + if (v !== null && typeof v === 'object' && + !isArray(v) && ObjectKeys(v).length > 2) + opt.depth = -1; + Object.assign(opt, this[kGetInspectOptions](this._stdout)); + return util.inspect(v, opt); + }; + const getIndexArray = (length) => ArrayFrom({ length }, (_, i) => inspect(i)); + + const mapIter = isMapIterator(tabularData); + let isKeyValue = false; + let i = 0; + if (mapIter) { + const res = previewEntries(tabularData, true); + tabularData = res[0]; + isKeyValue = res[1]; + } + + if (isKeyValue || isMap(tabularData)) { + const keys = []; + const values = []; + let length = 0; + if (mapIter) { + for (; i < tabularData.length / 2; ++i) { + keys.push(inspect(tabularData[i * 2])); + values.push(inspect(tabularData[i * 2 + 1])); + length++; + } + } else { + for (const [k, v] of tabularData) { + keys.push(inspect(k)); + values.push(inspect(v)); + length++; + } + } + return final([ + iterKey, keyKey, valuesKey + ], [ + getIndexArray(length), + keys, + values, + ]); + } + + const setIter = isSetIterator(tabularData); + if (setIter) + tabularData = previewEntries(tabularData); + + const setlike = setIter || (mapIter && !isKeyValue) || isSet(tabularData); + if (setlike) { + const values = []; + let length = 0; + for (const v of tabularData) { + values.push(inspect(v)); + length++; + } + return final([setlike ? iterKey : indexKey, valuesKey], [ + getIndexArray(length), + values, + ]); + } + + const map = {}; + let hasPrimitives = false; + const valuesKeyArray = []; + const indexKeyArray = ObjectKeys(tabularData); + + for (; i < indexKeyArray.length; i++) { + const item = tabularData[indexKeyArray[i]]; + const primitive = item === null || + (typeof item !== 'function' && typeof item !== 'object'); + if (properties === undefined && primitive) { + hasPrimitives = true; + valuesKeyArray[i] = inspect(item); + } else { + const keys = properties || ObjectKeys(item); + for (const key of keys) { + if (map[key] === undefined) + map[key] = []; + if ((primitive && properties) || !hasOwnProperty(item, key)) + map[key][i] = ''; + else + map[key][i] = item == null ? item : inspect(item[key]); + } + } + } + + const keys = ObjectKeys(map); + const values = ObjectValues(map); + if (hasPrimitives) { + keys.push(valuesKey); + values.push(valuesKeyArray); + } + keys.unshift(indexKey); + values.unshift(indexKeyArray); + + return final(keys, values); +}; + +function noop() {} + +module.exports = { + Console, + kBindStreamsLazy, + kBindProperties +}; diff --git a/lib/internal/http2/compat.js b/lib/internal/http2/compat.js index adf6b1da628881..1783a48ada814c 100644 --- a/lib/internal/http2/compat.js +++ b/lib/internal/http2/compat.js @@ -231,7 +231,7 @@ function onStreamCloseRequest() { state.closed = true; req.push(null); - // if the user didn't interact with incoming data and didn't pipe it, + // If the user didn't interact with incoming data and didn't pipe it, // dump it for compatibility with http1 if (!state.didRead && !req._readableState.resumeScheduled) req.resume(); diff --git a/lib/internal/http2/core.js b/lib/internal/http2/core.js index 80bcef5fa21633..6ce426a207a488 100644 --- a/lib/internal/http2/core.js +++ b/lib/internal/http2/core.js @@ -266,7 +266,7 @@ function onSessionHeaders(handle, id, cat, flags, headers) { if (stream === undefined) { if (session.closed) { - // we are not accepting any new streams at this point. This callback + // We are not accepting any new streams at this point. This callback // should not be invoked at this point in time, but just in case it is, // refuse the stream using an RST_STREAM and destroy the handle. handle.rstStream(NGHTTP2_REFUSED_STREAM); @@ -1112,7 +1112,7 @@ class Http2Session extends EventEmitter { return this[kState].goawayLastStreamID || 0; } - // true if the Http2Session is waiting for a settings acknowledgement + // True if the Http2Session is waiting for a settings acknowledgement get pendingSettingsAck() { return this[kState].pendingAck > 0; } @@ -2235,7 +2235,7 @@ class ServerHttp2Stream extends Http2Stream { this[kSession].remoteSettings.enablePush; } - // create a push stream, call the given callback with the created + // Create a push stream, call the given callback with the created // Http2Stream for the push stream. pushStream(headers, options, callback) { if (!this.pushAllowed) diff --git a/lib/internal/http2/util.js b/lib/internal/http2/util.js index 9dc8be6e83ddeb..f62d936025229f 100644 --- a/lib/internal/http2/util.js +++ b/lib/internal/http2/util.js @@ -290,7 +290,7 @@ function getDefaultSettings() { return holder; } -// remote is a boolean. true to fetch remote settings, false to fetch local. +// Remote is a boolean. true to fetch remote settings, false to fetch local. // this is only called internally function getSettings(session, remote) { if (remote) diff --git a/lib/internal/modules/cjs/loader.js b/lib/internal/modules/cjs/loader.js index 2ba5e0818b644e..d79f375ba60b44 100644 --- a/lib/internal/modules/cjs/loader.js +++ b/lib/internal/modules/cjs/loader.js @@ -138,7 +138,7 @@ const debug = util.debuglog('module'); Module._debug = util.deprecate(debug, 'Module._debug is deprecated.', 'DEP0077'); -// given a module name, and a list of paths to test, returns the first +// Given a module name, and a list of paths to test, returns the first // matching file in the following precedence. // // require("a.") @@ -207,7 +207,7 @@ function toRealPath(requestPath) { }); } -// given a path, check if the file exists with any of the set extensions +// Given a path, check if the file exists with any of the set extensions function tryExtensions(p, exts, isMain) { for (var i = 0; i < exts.length; i++) { const filename = tryFile(p + exts[i], isMain); @@ -452,7 +452,7 @@ Module._resolveLookupPaths = function(request, parent, newReturn) { // with --eval, parent.id is not set and parent.filename is null if (!parent || !parent.id || !parent.filename) { - // make require('./path/to/foo') work - normally the path is taken + // Make require('./path/to/foo') work - normally the path is taken // from realpath(__filename) but with eval there is no filename var mainPaths = ['.'].concat(Module._nodeModulePaths('.'), modulePaths); @@ -498,7 +498,7 @@ Module._resolveLookupPaths = function(request, parent, newReturn) { } var id = path.resolve(parentIdPath, request); - // make sure require('./path') and require('path') get distinct ids, even + // Make sure require('./path') and require('path') get distinct ids, even // when called from the toplevel js file if (parentIdPath === '.' && id.indexOf('/') === -1 && @@ -625,7 +625,7 @@ Module.prototype.load = function(filename) { const ESMLoader = asyncESM.ESMLoader; const url = `${pathToFileURL(filename)}`; const module = ESMLoader.moduleMap.get(url); - // create module entry at load time to snapshot exports correctly + // Create module entry at load time to snapshot exports correctly const exports = this.exports; if (module !== undefined) { // called from cjs translator module.reflect.onReady((reflect) => { diff --git a/lib/internal/modules/esm/translators.js b/lib/internal/modules/esm/translators.js index 0d19a728aa788b..6bfc4c8a98ed83 100644 --- a/lib/internal/modules/esm/translators.js +++ b/lib/internal/modules/esm/translators.js @@ -67,7 +67,7 @@ translators.set('cjs', async (url, isMain) => { } return createDynamicModule(['default'], url, () => { debug(`Loading CJSModule ${url}`); - // we don't care about the return val of _load here because Module#load + // We don't care about the return val of _load here because Module#load // will handle it for us by checking the loader registry and filling the // exports like above CJSModule._load(pathname, undefined, isMain); diff --git a/lib/internal/repl/recoverable.js b/lib/internal/repl/recoverable.js index 023de2f7abcf73..2c31db9faf6d80 100644 --- a/lib/internal/repl/recoverable.js +++ b/lib/internal/repl/recoverable.js @@ -45,7 +45,7 @@ function isRecoverableError(e, code) { case 'Unterminated string constant': const token = this.input.slice(this.lastTokStart, this.pos); - // see https://www.ecma-international.org/ecma-262/#sec-line-terminators + // See https://www.ecma-international.org/ecma-262/#sec-line-terminators recoverable = /\\(?:\r\n?|\n|\u2028|\u2029)$/.test(token); } diff --git a/lib/internal/streams/destroy.js b/lib/internal/streams/destroy.js index ce9d2545e45022..de6bcf9cdb1b9a 100644 --- a/lib/internal/streams/destroy.js +++ b/lib/internal/streams/destroy.js @@ -17,14 +17,14 @@ function destroy(err, cb) { return this; } - // we set destroyed to true before firing error callbacks in order + // We set destroyed to true before firing error callbacks in order // to make it re-entrance safe in case destroy() is called within callbacks if (this._readableState) { this._readableState.destroyed = true; } - // if this is a duplex stream mark the writable part as destroyed as well + // If this is a duplex stream mark the writable part as destroyed as well if (this._writableState) { this._writableState.destroyed = true; } diff --git a/lib/internal/timers.js b/lib/internal/timers.js index 3bfa1f03775fe1..fc9979e4b54e65 100644 --- a/lib/internal/timers.js +++ b/lib/internal/timers.js @@ -123,7 +123,7 @@ function setUnrefTimeout(callback, after, arg1, arg2, arg3) { default: args = [arg1, arg2, arg3]; for (i = 5; i < arguments.length; i++) { - // extend array dynamically, makes .apply run much faster in v6.0.0 + // Extend array dynamically, makes .apply run much faster in v6.0.0 args[i - 2] = arguments[i]; } break; diff --git a/lib/net.js b/lib/net.js index 0229e450fc6e10..2ce2b03fef846e 100644 --- a/lib/net.js +++ b/lib/net.js @@ -209,7 +209,7 @@ function normalizeArgs(args) { } -// called when creating new Socket, or when re-using a closed Socket +// Called when creating new Socket, or when re-using a closed Socket function initSocketHandle(self) { self._undestroy(); self._sockname = null; @@ -1266,10 +1266,10 @@ function setupListenHandle(address, port, addressType, backlog, fd, flags) { return; } - // generate connection key, this should be unique to the connection + // Generate connection key, this should be unique to the connection this._connectionKey = addressType + ':' + address + ':' + port; - // unref the handle if the server was unref'ed prior to listening + // Unref the handle if the server was unref'ed prior to listening if (this._unref) this.unref(); diff --git a/lib/readline.js b/lib/readline.js index 6fad26db4dff28..e4d9e1aa45fbf5 100644 --- a/lib/readline.js +++ b/lib/readline.js @@ -356,7 +356,7 @@ Interface.prototype._refreshLine = function() { // cursor position var cursorPos = this._getCursorPos(); - // first move to the bottom of the current line, based on cursor pos + // First move to the bottom of the current line, based on cursor pos var prevRows = this.prevRows || 0; if (prevRows > 0) { moveCursor(this.output, 0, -prevRows); @@ -444,7 +444,7 @@ Interface.prototype._normalWrite = function(b) { // got one or more newlines; process into "line" events var lines = string.split(lineEnding); - // either '' or (conceivably) the unfinished portion of the next line + // Either '' or (conceivably) the unfinished portion of the next line string = lines.pop(); this._line_buffer = string; for (var n = 0; n < lines.length; n++) diff --git a/lib/timers.js b/lib/timers.js index 1531cd1fb60726..4f2fef449db211 100644 --- a/lib/timers.js +++ b/lib/timers.js @@ -389,7 +389,7 @@ function unenroll(item) { } item[kRefed] = null; - // if active is called later, then we want to make sure not to insert again + // If active is called later, then we want to make sure not to insert again item._idleTimeout = -1; } @@ -444,7 +444,7 @@ function setTimeout(callback, after, arg1, arg2, arg3) { default: args = [arg1, arg2, arg3]; for (i = 5; i < arguments.length; i++) { - // extend array dynamically, makes .apply run much faster in v6.0.0 + // Extend array dynamically, makes .apply run much faster in v6.0.0 args[i - 2] = arguments[i]; } break; @@ -493,7 +493,7 @@ exports.setInterval = function setInterval(callback, repeat, arg1, arg2, arg3) { default: args = [arg1, arg2, arg3]; for (i = 5; i < arguments.length; i++) { - // extend array dynamically, makes .apply run much faster in v6.0.0 + // Extend array dynamically, makes .apply run much faster in v6.0.0 args[i - 2] = arguments[i]; } break; @@ -712,7 +712,7 @@ function setImmediate(callback, arg1, arg2, arg3) { default: args = [arg1, arg2, arg3]; for (i = 4; i < arguments.length; i++) { - // extend array dynamically, makes .apply run much faster in v6.0.0 + // Extend array dynamically, makes .apply run much faster in v6.0.0 args[i - 1] = arguments[i]; } break; diff --git a/lib/url.js b/lib/url.js index eac9d1511b9f8c..29dec5cc5f91c2 100644 --- a/lib/url.js +++ b/lib/url.js @@ -461,7 +461,7 @@ Url.prototype.parse = function parse(url, parseQueryString, slashesDenoteHost) { this.path = p + s; } - // finally, reconstruct the href based on what has been validated. + // Finally, reconstruct the href based on what has been validated. this.href = this.format(); return this; }; @@ -629,7 +629,7 @@ Url.prototype.format = function format() { pathname = newPathname; } - // only the slashedProtocols get the //. Not mailto:, xmpp:, etc. + // Only the slashedProtocols get the //. Not mailto:, xmpp:, etc. // unless they had them to begin with. if (this.slashes || slashedProtocol.has(protocol)) { if (this.slashes || host) { @@ -686,7 +686,7 @@ Url.prototype.resolveObject = function resolveObject(relative) { // even href="" will remove it. result.hash = relative.hash; - // if the relative url is empty, then there's nothing left to do here. + // If the relative url is empty, then there's nothing left to do here. if (relative.href === '') { result.href = result.format(); return result; @@ -888,7 +888,7 @@ Url.prototype.resolveObject = function resolveObject(relative) { } } - // if the path is allowed to go above the root, restore leading ..s + // If the path is allowed to go above the root, restore leading ..s if (!mustEndAbs && !removeAllDots) { while (up--) { srcPath.unshift('..'); diff --git a/lib/util.js b/lib/util.js index cd96db044a834b..922a01f357e408 100644 --- a/lib/util.js +++ b/lib/util.js @@ -278,7 +278,7 @@ function timestamp() { return [d.getDate(), months[d.getMonth()], time].join(' '); } -// log is just a thin wrapper to console.log that prepends a timestamp +// Log is just a thin wrapper to console.log that prepends a timestamp function log() { console.log('%s - %s', timestamp(), exports.format.apply(exports, arguments)); } diff --git a/lib/zlib.js b/lib/zlib.js index 559f6c2d5f3056..2ecec19f3064e9 100644 --- a/lib/zlib.js +++ b/lib/zlib.js @@ -510,7 +510,7 @@ function processChunkSync(self, chunk, flushFlag) { assert(have === 0, 'have should not go down'); } - // exhausted the output buffer, or used all the input create a new one. + // Exhausted the output buffer, or used all the input create a new one. if (availOutAfter === 0 || offset >= chunkSize) { availOutBefore = chunkSize; offset = 0; @@ -599,7 +599,7 @@ function processCallback() { return; } - // exhausted the output buffer, or used all the input create a new one. + // Exhausted the output buffer, or used all the input create a new one. if (availOutAfter === 0 || self._outOffset >= self._chunkSize) { handle.availOutBefore = self._chunkSize; self._outOffset = 0; diff --git a/test/abort/test-abort-backtrace.js b/test/abort/test-abort-backtrace.js index 7f87ef0e7f4559..b609ec7e4e6a7a 100644 --- a/test/abort/test-abort-backtrace.js +++ b/test/abort/test-abort-backtrace.js @@ -10,7 +10,7 @@ if (process.argv[2] === 'child') { const stderr = child.stderr.toString(); assert.strictEqual(child.stdout.toString(), ''); - // stderr will be empty for systems that don't support backtraces. + // Stderr will be empty for systems that don't support backtraces. if (stderr !== '') { const frames = stderr.trimRight().split('\n').map((s) => s.trim()); diff --git a/test/async-hooks/test-async-await.js b/test/async-hooks/test-async-await.js index 0103f63621e3ba..8aee59a36ff561 100644 --- a/test/async-hooks/test-async-await.js +++ b/test/async-hooks/test-async-await.js @@ -14,7 +14,7 @@ const util = require('util'); const sleep = util.promisify(setTimeout); // either 'inited' or 'resolved' const promisesInitState = new Map(); -// either 'before' or 'after' AND asyncId must be present in the other map +// Either 'before' or 'after' AND asyncId must be present in the other map const promisesExecutionState = new Map(); const hooks = initHooks({ diff --git a/test/async-hooks/test-embedder.api.async-resource.after-on-destroyed.js b/test/async-hooks/test-embedder.api.async-resource.after-on-destroyed.js index 3cf0cc430f0fe0..a389eddf421cc8 100644 --- a/test/async-hooks/test-embedder.api.async-resource.after-on-destroyed.js +++ b/test/async-hooks/test-embedder.api.async-resource.after-on-destroyed.js @@ -14,7 +14,7 @@ if (process.argv[2] === 'child') { const hooks = initHooks(); hooks.enable(); - // once 'destroy' has been emitted, we can no longer emit 'after' + // Once 'destroy' has been emitted, we can no longer emit 'after' // Emitting 'before', 'after' and then 'destroy' const event1 = new AsyncResource('event1', async_hooks.executionAsyncId()); diff --git a/test/async-hooks/test-embedder.api.async-resource.before-on-destroyed.js b/test/async-hooks/test-embedder.api.async-resource.before-on-destroyed.js index 6463c438ed9102..d6465a8445282d 100644 --- a/test/async-hooks/test-embedder.api.async-resource.before-on-destroyed.js +++ b/test/async-hooks/test-embedder.api.async-resource.before-on-destroyed.js @@ -14,7 +14,7 @@ if (process.argv[2] === 'child') { const hooks = initHooks(); hooks.enable(); - // once 'destroy' has been emitted, we can no longer emit 'before' + // Once 'destroy' has been emitted, we can no longer emit 'before' // Emitting 'before', 'after' and then 'destroy' const event1 = new AsyncResource('event1', async_hooks.executionAsyncId()); diff --git a/test/async-hooks/test-embedder.api.async-resource.improper-order.js b/test/async-hooks/test-embedder.api.async-resource.improper-order.js index 048ae0841357ec..4a38d87ce21e1f 100644 --- a/test/async-hooks/test-embedder.api.async-resource.improper-order.js +++ b/test/async-hooks/test-embedder.api.async-resource.improper-order.js @@ -14,7 +14,7 @@ if (process.argv[2] === 'child') { const hooks = initHooks(); hooks.enable(); - // async hooks enforce proper order of 'before' and 'after' invocations + // Async hooks enforce proper order of 'before' and 'after' invocations // Proper ordering const event1 = new AsyncResource('event1', async_hooks.executionAsyncId()); diff --git a/test/async-hooks/test-embedder.api.async-resource.js b/test/async-hooks/test-embedder.api.async-resource.js index 6f71a3e98cbf0f..74d6c478c835bb 100644 --- a/test/async-hooks/test-embedder.api.async-resource.js +++ b/test/async-hooks/test-embedder.api.async-resource.js @@ -29,13 +29,13 @@ assert.strictEqual( async_hooks.executionAsyncId() ); -// create first custom event 'alcazares' with triggerAsyncId derived +// Create first custom event 'alcazares' with triggerAsyncId derived // from async_hooks executionAsyncId const alcaTriggerId = async_hooks.executionAsyncId(); const alcaEvent = new AsyncResource('alcazares', alcaTriggerId); const alcazaresActivities = hooks.activitiesOfTypes([ 'alcazares' ]); -// alcazares event was constructed and thus only has an `init` call +// Alcazares event was constructed and thus only has an `init` call assert.strictEqual(alcazaresActivities.length, 1); const alcazares = alcazaresActivities[0]; assert.strictEqual(alcazares.type, 'alcazares'); @@ -83,7 +83,7 @@ function tick1() { checkInvocations(poblado, { init: 1, before: 1, after: 1 }, 'poblado emitted after'); - // after we disable the hooks we shouldn't receive any events anymore + // After we disable the hooks we shouldn't receive any events anymore hooks.disable(); alcaEvent.emitDestroy(); tick(1, common.mustCall(tick2)); diff --git a/test/async-hooks/test-enable-disable.js b/test/async-hooks/test-enable-disable.js index c14a125688d0f4..f71fd63e1c7756 100644 --- a/test/async-hooks/test-enable-disable.js +++ b/test/async-hooks/test-enable-disable.js @@ -261,7 +261,7 @@ function onexit() { 'hook2Second: when process exits'); checkInvocations(hook3First, { init: 1, before: 1, after: 1, destroy: 1 }, 'hook3First: when process exits'); - // we don't see a "destroy" invocation here since hook3 disabled itself + // We don't see a "destroy" invocation here since hook3 disabled itself // during its "after" invocation checkInvocations(hook3Second, { init: 1, before: 1, after: 1 }, 'hook3Second: when process exits'); diff --git a/test/async-hooks/test-fsreqcallback-readFile.js b/test/async-hooks/test-fsreqcallback-readFile.js index 3ae31378cd3199..01ccce9b4cc694 100644 --- a/test/async-hooks/test-fsreqcallback-readFile.js +++ b/test/async-hooks/test-fsreqcallback-readFile.js @@ -32,7 +32,7 @@ function onread() { checkInvocations(as[2], { init: 1, before: 1, after: 1, destroy: 1 }, 'reqwrap[2]: while in onread callback'); - // this callback is called from within the last fs req callback therefore + // This callback is called from within the last fs req callback therefore // the last req is still going and after/destroy haven't been called yet checkInvocations(as[3], { init: 1, before: 1 }, 'reqwrap[3]: while in onread callback'); diff --git a/test/async-hooks/test-pipeconnectwrap.js b/test/async-hooks/test-pipeconnectwrap.js index 6c68186e2f239f..5d3706ac44fef6 100644 --- a/test/async-hooks/test-pipeconnectwrap.js +++ b/test/async-hooks/test-pipeconnectwrap.js @@ -53,7 +53,7 @@ function onlisten() { const awaitOnconnectCalls = new Set(['server', 'client']); function maybeOnconnect(source) { - // both server and client must call onconnect. On most OS's waiting for + // Both server and client must call onconnect. On most OS's waiting for // the client is sufficient, but on CentOS 5 the sever needs to respond too. assert.ok(awaitOnconnectCalls.size > 0); awaitOnconnectCalls.delete(source); diff --git a/test/async-hooks/test-pipewrap.js b/test/async-hooks/test-pipewrap.js index a632115d228d64..0a4d082856df22 100644 --- a/test/async-hooks/test-pipewrap.js +++ b/test/async-hooks/test-pipewrap.js @@ -22,7 +22,7 @@ nodeVersionSpawn .on('exit', common.mustCall(onsleepExit)) .on('close', common.mustCall(onsleepClose)); -// a process wrap and 3 pipe wraps for std{in,out,err} are initialized +// A process wrap and 3 pipe wraps for std{in,out,err} are initialized // synchronously const processes = hooks.activitiesOfTypes('PROCESSWRAP'); const pipes = hooks.activitiesOfTypes('PIPEWRAP'); diff --git a/test/async-hooks/test-promise.promise-before-init-hooks.js b/test/async-hooks/test-promise.promise-before-init-hooks.js index f9ba24c044298f..0f74c968e6a25e 100644 --- a/test/async-hooks/test-promise.promise-before-init-hooks.js +++ b/test/async-hooks/test-promise.promise-before-init-hooks.js @@ -32,7 +32,7 @@ process.on('exit', function onexit() { const a0 = as[0]; assert.strictEqual(a0.type, 'PROMISE'); assert.strictEqual(typeof a0.uid, 'number'); - // we can't get the asyncId from the parent dynamically, since init was + // We can't get the asyncId from the parent dynamically, since init was // never called. However, it is known that the parent promise was created // immediately before the child promise, thus there should only be one // difference in id. diff --git a/test/async-hooks/test-signalwrap.js b/test/async-hooks/test-signalwrap.js index c94d763450ab24..5bc02e6dc46204 100644 --- a/test/async-hooks/test-signalwrap.js +++ b/test/async-hooks/test-signalwrap.js @@ -92,7 +92,7 @@ function onexit() { checkInvocations( signal1, { init: 1, before: 2, after: 2, destroy: 1 }, 'signal1: when second SIGUSR2 process exits'); - // second signal not destroyed yet since its event listener is still active + // Second signal not destroyed yet since its event listener is still active checkInvocations( signal2, { init: 1, before: 1, after: 1 }, 'signal2: when second SIGUSR2 process exits'); diff --git a/test/common/index.js b/test/common/index.js index 7b668e58c48ead..33089e69af6072 100644 --- a/test/common/index.js +++ b/test/common/index.js @@ -336,7 +336,7 @@ function _mustCallInner(fn, criteria = 1, field) { name: fn.name || '' }; - // add the exit listener only once to avoid listener leak warnings + // Add the exit listener only once to avoid listener leak warnings if (mustCallChecks.length === 0) process.on('exit', runCallChecks); mustCallChecks.push(context); @@ -392,7 +392,7 @@ function getCallSite(top) { `${stack[0].getFileName()}:${stack[0].getLineNumber()}`; const err = new Error(); Error.captureStackTrace(err, top); - // with the V8 Error API, the stack is not formatted until it is accessed + // With the V8 Error API, the stack is not formatted until it is accessed err.stack; Error.prepareStackTrace = originalStackFormatter; return err.stack; @@ -507,7 +507,7 @@ function expectWarningByMap(warningMap) { process.on('warning', (warning) => catchWarning[warning.name](warning)); } -// accepts a warning name and description or array of descriptions or a map +// Accepts a warning name and description or array of descriptions or a map // of warning names to description(s) // ensures a warning is generated for each name/description pair function expectWarning(nameOrMap, expected, code) { diff --git a/test/es-module/test-esm-preserve-symlinks-main.js b/test/es-module/test-esm-preserve-symlinks-main.js index fbca5dce743674..808b6c9a15f6fd 100644 --- a/test/es-module/test-esm-preserve-symlinks-main.js +++ b/test/es-module/test-esm-preserve-symlinks-main.js @@ -35,7 +35,7 @@ try { } function doTest(flags, done) { - // invoke the main file via a symlink. In this case --preserve-symlinks-main + // Invoke the main file via a symlink. In this case --preserve-symlinks-main // dictates that it'll resolve relative imports in the main file relative to // the symlink, and not relative to the symlink target; the file structure set // up above requires this to not crash when loading ./submodule_link.js diff --git a/test/js-native-api/test_general/test.js b/test/js-native-api/test_general/test.js index a8548bcdf916a4..7a65297cd3a368 100644 --- a/test/js-native-api/test_general/test.js +++ b/test/js-native-api/test_general/test.js @@ -48,7 +48,7 @@ assert.strictEqual(test_general.testGetVersion(), 3); assert.strictEqual(test_general.testNapiTypeof(val), typeof val); }); -// since typeof in js return object need to validate specific case +// Since typeof in js return object need to validate specific case // for null assert.strictEqual(test_general.testNapiTypeof(null), 'null'); diff --git a/test/js-native-api/test_number/test.js b/test/js-native-api/test_number/test.js index 34f48aee578ac6..a7a6009852d884 100644 --- a/test/js-native-api/test_number/test.js +++ b/test/js-native-api/test_number/test.js @@ -49,7 +49,7 @@ testUint32(4294967296, 0); testUint32(4294967297, 1); testUint32(17 * 4294967296 + 1, 1); -// validate documented behavior when value is retrieved as 32-bit integer with +// Validate documented behavior when value is retrieved as 32-bit integer with // `napi_get_value_int32` function testInt32(input, expected = input) { assert.strictEqual(expected, test_number.TestInt32Truncation(input)); @@ -92,7 +92,7 @@ testInt32(Number.POSITIVE_INFINITY, 0); testInt32(Number.NEGATIVE_INFINITY, 0); testInt32(Number.NaN, 0); -// validate documented behavior when value is retrieved as 64-bit integer with +// Validate documented behavior when value is retrieved as 64-bit integer with // `napi_get_value_int64` function testInt64(input, expected = input) { assert.strictEqual(expected, test_number.TestInt64Truncation(input)); diff --git a/test/known_issues/test-dgram-bind-shared-ports-after-port-0.js b/test/known_issues/test-dgram-bind-shared-ports-after-port-0.js index 7b750c765ba226..fbf88d41650d24 100644 --- a/test/known_issues/test-dgram-bind-shared-ports-after-port-0.js +++ b/test/known_issues/test-dgram-bind-shared-ports-after-port-0.js @@ -45,7 +45,7 @@ if (cluster.isMaster) { // worker code process.on('message', (msg) => msg === BYE && process.exit(0)); - // first worker will bind to '0', second will try the assigned port and fail + // First worker will bind to '0', second will try the assigned port and fail const PRT1 = process.env.PRT1 || 0; const socket1 = dgram.createSocket('udp4', () => {}); socket1.on('error', PRT1 === 0 ? () => {} : assert.fail); diff --git a/test/parallel/test-async-hooks-http-parser-destroy.js b/test/parallel/test-async-hooks-http-parser-destroy.js index aeb805702d89e9..d2e1071c280d66 100644 --- a/test/parallel/test-async-hooks-http-parser-destroy.js +++ b/test/parallel/test-async-hooks-http-parser-destroy.js @@ -36,7 +36,7 @@ const keepAliveAgent = new http.Agent({ const countdown = new Countdown(N, () => { server.close(() => { - // give the server sockets time to close (which will also free their + // Give the server sockets time to close (which will also free their // associated parser objects) after the server has been closed. setTimeout(() => { createdIds.forEach((createdAsyncId) => { diff --git a/test/parallel/test-buffer-alloc.js b/test/parallel/test-buffer-alloc.js index bdba19ae66ddb5..cee87994965493 100644 --- a/test/parallel/test-buffer-alloc.js +++ b/test/parallel/test-buffer-alloc.js @@ -106,7 +106,7 @@ b.copy(Buffer.alloc(1), 1, 1, 1); // try to copy 0 bytes from past the end of the source buffer b.copy(Buffer.alloc(1), 0, 2048, 2048); -// testing for smart defaults and ability to pass string values as offset +// Testing for smart defaults and ability to pass string values as offset { const writeTest = Buffer.from('abcdes'); writeTest.write('n', 'ascii'); @@ -799,7 +799,7 @@ common.expectsError( outOfRangeError ); -// attempt to overflow buffers, similar to previous bug in array buffers +// Attempt to overflow buffers, similar to previous bug in array buffers common.expectsError( () => Buffer.allocUnsafe(8).writeFloatLE(0.0, 0xffffffff), outOfRangeError diff --git a/test/parallel/test-buffer-compare-offset.js b/test/parallel/test-buffer-compare-offset.js index a437d8fa6345f6..47e5f3041e12e6 100644 --- a/test/parallel/test-buffer-compare-offset.js +++ b/test/parallel/test-buffer-compare-offset.js @@ -54,7 +54,7 @@ assert.strictEqual(a.compare(b, 0, { valueOf: () => 5 }), -1); // zero length target assert.strictEqual(a.compare(b, Infinity, -Infinity), 1); -// zero length target because default for targetEnd <= targetSource +// Zero length target because default for targetEnd <= targetSource assert.strictEqual(a.compare(b, '0xff'), 1); const oor = common.expectsError({ code: 'ERR_OUT_OF_RANGE' }, 7); diff --git a/test/parallel/test-buffer-copy.js b/test/parallel/test-buffer-copy.js index 6fb6a4ec707ef0..e9f789a88623e7 100644 --- a/test/parallel/test-buffer-copy.js +++ b/test/parallel/test-buffer-copy.js @@ -108,7 +108,7 @@ common.expectsError( errorProperty); { - // check sourceEnd resets to targetEnd if former is greater than the latter + // Check sourceEnd resets to targetEnd if former is greater than the latter b.fill(++cntr); c.fill(++cntr); b.copy(c, 0, 0, 1025); diff --git a/test/parallel/test-buffer-read.js b/test/parallel/test-buffer-read.js index 6f4ff3ca86f5e9..94e198fedca7b1 100644 --- a/test/parallel/test-buffer-read.js +++ b/test/parallel/test-buffer-read.js @@ -13,22 +13,22 @@ function read(buff, funx, args, expected) { ); } -// testing basic functionality of readDoubleBE() and readDoubleLE() +// Testing basic functionality of readDoubleBE() and readDoubleLE() read(buf, 'readDoubleBE', [1], -3.1827727774563287e+295); read(buf, 'readDoubleLE', [1], -6.966010051009108e+144); -// testing basic functionality of readFloatBE() and readFloatLE() +// Testing basic functionality of readFloatBE() and readFloatLE() read(buf, 'readFloatBE', [1], -1.6691549692541768e+37); read(buf, 'readFloatLE', [1], -7861303808); // testing basic functionality of readInt8() read(buf, 'readInt8', [1], -3); -// testing basic functionality of readInt16BE() and readInt16LE() +// Testing basic functionality of readInt16BE() and readInt16LE() read(buf, 'readInt16BE', [1], -696); read(buf, 'readInt16LE', [1], 0x48fd); -// testing basic functionality of readInt32BE() and readInt32LE() +// Testing basic functionality of readInt32BE() and readInt32LE() read(buf, 'readInt32BE', [1], -45552945); read(buf, 'readInt32LE', [1], -806729475); @@ -39,11 +39,11 @@ read(buf, 'readIntLE', [2, 1], 0x48); // testing basic functionality of readUInt8() read(buf, 'readUInt8', [1], 0xfd); -// testing basic functionality of readUInt16BE() and readUInt16LE() +// Testing basic functionality of readUInt16BE() and readUInt16LE() read(buf, 'readUInt16BE', [2], 0x48ea); read(buf, 'readUInt16LE', [2], 0xea48); -// testing basic functionality of readUInt32BE() and readUInt32LE() +// Testing basic functionality of readUInt32BE() and readUInt32LE() read(buf, 'readUInt32BE', [1], 0xfd48eacf); read(buf, 'readUInt32LE', [1], 0xcfea48fd); diff --git a/test/parallel/test-buffer-tostring-range.js b/test/parallel/test-buffer-tostring-range.js index f6ee846dd8ef34..436414e1b7da55 100644 --- a/test/parallel/test-buffer-tostring-range.js +++ b/test/parallel/test-buffer-tostring-range.js @@ -35,7 +35,7 @@ assert.strictEqual(rangeBuffer.toString('ascii', undefined, 3), 'abc'); assert.strictEqual(rangeBuffer.toString('ascii', false, 3), 'abc'); assert.strictEqual(rangeBuffer.toString('ascii', '', 3), 'abc'); -// but, if start is an integer when coerced, then it will be coerced and used. +// But, if start is an integer when coerced, then it will be coerced and used. assert.strictEqual(rangeBuffer.toString('ascii', '-1', 3), 'abc'); assert.strictEqual(rangeBuffer.toString('ascii', '1', 3), 'bc'); assert.strictEqual(rangeBuffer.toString('ascii', '-Infinity', 3), 'abc'); @@ -47,7 +47,7 @@ assert.strictEqual(rangeBuffer.toString('ascii', '-1.99', 3), 'abc'); assert.strictEqual(rangeBuffer.toString('ascii', 1.99, 3), 'bc'); assert.strictEqual(rangeBuffer.toString('ascii', true, 3), 'bc'); -// if end > buffer's length, end will be taken as buffer's length +// If end > buffer's length, end will be taken as buffer's length assert.strictEqual(rangeBuffer.toString('ascii', 0, 5), 'abc'); assert.strictEqual(rangeBuffer.toString('ascii', 0, 6.99), 'abc'); assert.strictEqual(rangeBuffer.toString('ascii', 0, Infinity), 'abc'); @@ -55,7 +55,7 @@ assert.strictEqual(rangeBuffer.toString('ascii', 0, '5'), 'abc'); assert.strictEqual(rangeBuffer.toString('ascii', 0, '6.99'), 'abc'); assert.strictEqual(rangeBuffer.toString('ascii', 0, 'Infinity'), 'abc'); -// if end is an invalid integer, end will be taken as buffer's length +// If end is an invalid integer, end will be taken as buffer's length assert.strictEqual(rangeBuffer.toString('ascii', 0, 'node.js'), ''); assert.strictEqual(rangeBuffer.toString('ascii', 0, {}), ''); assert.strictEqual(rangeBuffer.toString('ascii', 0, NaN), ''); @@ -66,7 +66,7 @@ assert.strictEqual(rangeBuffer.toString('ascii', 0, []), ''); assert.strictEqual(rangeBuffer.toString('ascii', 0, false), ''); assert.strictEqual(rangeBuffer.toString('ascii', 0, ''), ''); -// but, if end is an integer when coerced, then it will be coerced and used. +// But, if end is an integer when coerced, then it will be coerced and used. assert.strictEqual(rangeBuffer.toString('ascii', 0, '-1'), ''); assert.strictEqual(rangeBuffer.toString('ascii', 0, '1'), 'a'); assert.strictEqual(rangeBuffer.toString('ascii', 0, '-Infinity'), ''); diff --git a/test/parallel/test-child-process-spawn-typeerror.js b/test/parallel/test-child-process-spawn-typeerror.js index 82acaf8e088038..71bfdfdfe8f24f 100644 --- a/test/parallel/test-child-process-spawn-typeerror.js +++ b/test/parallel/test-child-process-spawn-typeerror.js @@ -91,7 +91,7 @@ const s = 'string'; const u = undefined; const n = null; -// function spawn(file=f [,args=a] [, options=o]) has valid combinations: +// Function spawn(file=f [,args=a] [, options=o]) has valid combinations: // (f) // (f, a) // (f, a, o) diff --git a/test/parallel/test-child-process-stdout-flush-exit.js b/test/parallel/test-child-process-stdout-flush-exit.js index f3fdf4949aadd5..679d78269fc441 100644 --- a/test/parallel/test-child-process-stdout-flush-exit.js +++ b/test/parallel/test-child-process-stdout-flush-exit.js @@ -45,7 +45,7 @@ if (process.argv[2] === 'child') { assert.fail(`Unexpected parent stderr: ${data}`); }); - // check if we receive both 'hello' at start and 'goodbye' at end + // Check if we receive both 'hello' at start and 'goodbye' at end child.stdout.setEncoding('utf8'); child.stdout.on('data', function(data) { stdout += data; diff --git a/test/parallel/test-cluster-setup-master-multiple.js b/test/parallel/test-cluster-setup-master-multiple.js index b33acccd411a0a..33d490df45f57a 100644 --- a/test/parallel/test-cluster-setup-master-multiple.js +++ b/test/parallel/test-cluster-setup-master-multiple.js @@ -62,7 +62,7 @@ execs.forEach((v, i) => { }, i * 100); }); -// cluster emits 'setup' asynchronously, so we must stay alive long +// Cluster emits 'setup' asynchronously, so we must stay alive long // enough for that to happen setTimeout(() => { console.log('cluster setup complete'); diff --git a/test/parallel/test-cluster-worker-forced-exit.js b/test/parallel/test-cluster-worker-forced-exit.js index cc76b4ba3aff3a..6d2bf4f53747d6 100644 --- a/test/parallel/test-cluster-worker-forced-exit.js +++ b/test/parallel/test-cluster-worker-forced-exit.js @@ -26,7 +26,7 @@ const cluster = require('cluster'); const SENTINEL = 42; -// workers forcibly exit when control channel is disconnected, if +// Workers forcibly exit when control channel is disconnected, if // their .exitedAfterDisconnect flag isn't set // // test this by: diff --git a/test/parallel/test-cluster-worker-no-exit.js b/test/parallel/test-cluster-worker-no-exit.js index b87b58b3f8b74a..ecd7c47f5aa568 100644 --- a/test/parallel/test-cluster-worker-no-exit.js +++ b/test/parallel/test-cluster-worker-no-exit.js @@ -30,7 +30,7 @@ let success; let worker; let server; -// workers do not exit on disconnect, they exit under normal node rules: when +// Workers do not exit on disconnect, they exit under normal node rules: when // they have nothing keeping their loop alive, like an active connection // // test this by: diff --git a/test/parallel/test-console.js b/test/parallel/test-console.js index 92e66596d76ca7..f781d619946e1a 100644 --- a/test/parallel/test-console.js +++ b/test/parallel/test-console.js @@ -174,7 +174,7 @@ console.timeEnd(); console.time(NaN); console.timeEnd(NaN); -// make sure calling time twice without timeEnd doesn't reset the timer. +// Make sure calling time twice without timeEnd doesn't reset the timer. console.time('test'); const time = console._times.get('test'); setTimeout(() => { @@ -248,7 +248,7 @@ assert.ok(/^__proto__: \d+\.\d{3}ms$/.test(strings.shift().trim())); assert.ok(/^constructor: \d+\.\d{3}ms$/.test(strings.shift().trim())); assert.ok(/^hasOwnProperty: \d+\.\d{3}ms$/.test(strings.shift().trim())); -// verify that console.time() coerces label values to strings as expected +// Verify that console.time() coerces label values to strings as expected assert.ok(/^: \d+\.\d{3}ms$/.test(strings.shift().trim())); assert.ok(/^\[object Object\]: \d+\.\d{3}ms$/.test(strings.shift().trim())); assert.ok(/^\[object Object\]: \d+\.\d{3}ms$/.test(strings.shift().trim())); diff --git a/test/parallel/test-crypto-authenticated.js b/test/parallel/test-crypto-authenticated.js index 01ce1d9996863e..b62ce1a5b088bc 100644 --- a/test/parallel/test-crypto-authenticated.js +++ b/test/parallel/test-crypto-authenticated.js @@ -122,7 +122,7 @@ for (const test of TEST_CASES) { hex += encrypt.final('hex'); const auth_tag = encrypt.getAuthTag(); - // only test basic encryption run if output is marked as tampered. + // Only test basic encryption run if output is marked as tampered. if (!test.tampered) { assert.strictEqual(hex, test.ct); assert.strictEqual(auth_tag.toString('hex'), test.tag); @@ -170,7 +170,7 @@ for (const test of TEST_CASES) { let hex = encrypt.update(test.plain, 'ascii', 'hex'); hex += encrypt.final('hex'); const auth_tag = encrypt.getAuthTag(); - // only test basic encryption run if output is marked as tampered. + // Only test basic encryption run if output is marked as tampered. if (!test.tampered) { assert.strictEqual(hex, test.ct); assert.strictEqual(auth_tag.toString('hex'), test.tag); diff --git a/test/parallel/test-dgram-bind-default-address.js b/test/parallel/test-dgram-bind-default-address.js index 762ead7c869e8d..130d614c5812b5 100644 --- a/test/parallel/test-dgram-bind-default-address.js +++ b/test/parallel/test-dgram-bind-default-address.js @@ -21,7 +21,7 @@ 'use strict'; const common = require('../common'); -// skip test in FreeBSD jails since 0.0.0.0 will resolve to default interface +// Skip test in FreeBSD jails since 0.0.0.0 will resolve to default interface if (common.inFreeBSDJail) common.skip('In a FreeBSD jail'); diff --git a/test/parallel/test-dgram-exclusive-implicit-bind.js b/test/parallel/test-dgram-exclusive-implicit-bind.js index 171b221ee2982c..4603507240f8b7 100644 --- a/test/parallel/test-dgram-exclusive-implicit-bind.js +++ b/test/parallel/test-dgram-exclusive-implicit-bind.js @@ -92,7 +92,7 @@ source.on('close', function() { if (process.env.BOUND === 'y') { source.bind(0); } else { - // cluster doesn't know about exclusive sockets, so it won't close them. This + // Cluster doesn't know about exclusive sockets, so it won't close them. This // is expected, its the same situation for timers, outgoing tcp connections, // etc, which also keep workers alive after disconnect was requested. source.unref(); diff --git a/test/parallel/test-dgram-ref.js b/test/parallel/test-dgram-ref.js index b3b8488297507c..0c5474b118bd6b 100644 --- a/test/parallel/test-dgram-ref.js +++ b/test/parallel/test-dgram-ref.js @@ -23,7 +23,7 @@ const common = require('../common'); const dgram = require('dgram'); -// should not hang, see https://github.com/nodejs/node-v0.x-archive/issues/1282 +// Should not hang, see https://github.com/nodejs/node-v0.x-archive/issues/1282 dgram.createSocket('udp4'); dgram.createSocket('udp6'); diff --git a/test/parallel/test-domain-crypto.js b/test/parallel/test-domain-crypto.js index 26ee6b888efb2d..cb397c2fe33eb6 100644 --- a/test/parallel/test-domain-crypto.js +++ b/test/parallel/test-domain-crypto.js @@ -33,7 +33,7 @@ common.allowGlobals(require('domain')); // See https://github.com/nodejs/node/commit/d1eff9ab global.domain = require('domain'); -// should not throw a 'TypeError: undefined is not a function' exception +// Should not throw a 'TypeError: undefined is not a function' exception crypto.randomBytes(8); crypto.randomBytes(8, common.mustCall()); const buf = Buffer.alloc(8); diff --git a/test/parallel/test-domain-from-timer.js b/test/parallel/test-domain-from-timer.js index 3f8252543c9d2f..419a8aa96eb38f 100644 --- a/test/parallel/test-domain-from-timer.js +++ b/test/parallel/test-domain-from-timer.js @@ -25,7 +25,7 @@ require('../common'); const assert = require('assert'); -// timeouts call the callback directly from cc, so need to make sure the +// Timeouts call the callback directly from cc, so need to make sure the // domain will be used regardless setTimeout(() => { const domain = require('domain'); diff --git a/test/parallel/test-event-emitter-check-listener-leaks.js b/test/parallel/test-event-emitter-check-listener-leaks.js index 7688c61a435cfb..037d090e6332a4 100644 --- a/test/parallel/test-event-emitter-check-listener-leaks.js +++ b/test/parallel/test-event-emitter-check-listener-leaks.js @@ -88,7 +88,7 @@ const events = require('events'); assert.ok(e._events.fortytwo.hasOwnProperty('warned')); } -// but _maxListeners still has precedence over defaultMaxListeners +// But _maxListeners still has precedence over defaultMaxListeners { events.EventEmitter.defaultMaxListeners = 42; const e = new events.EventEmitter(); diff --git a/test/parallel/test-force-repl-with-eval.js b/test/parallel/test-force-repl-with-eval.js index 8c75818508d17e..3f81d362d449b7 100644 --- a/test/parallel/test-force-repl-with-eval.js +++ b/test/parallel/test-force-repl-with-eval.js @@ -3,7 +3,7 @@ require('../common'); const assert = require('assert'); const spawn = require('child_process').spawn; -// spawn a node child process in "interactive" mode (force the repl) and eval +// Spawn a node child process in "interactive" mode (force the repl) and eval const cp = spawn(process.execPath, ['-i', '-e', 'console.log("42")']); let gotToEnd = false; diff --git a/test/parallel/test-fs-append-file.js b/test/parallel/test-fs-append-file.js index 4d8f66682ed634..20cba235f035b6 100644 --- a/test/parallel/test-fs-append-file.js +++ b/test/parallel/test-fs-append-file.js @@ -42,7 +42,7 @@ tmpdir.refresh(); const throwNextTick = (e) => { process.nextTick(() => { throw e; }); }; -// test that empty file will be created and have content added (callback API) +// Test that empty file will be created and have content added (callback API) { const filename = join(tmpdir.path, 'append.txt'); @@ -56,7 +56,7 @@ const throwNextTick = (e) => { process.nextTick(() => { throw e; }); }; })); } -// test that empty file will be created and have content added (promise API) +// Test that empty file will be created and have content added (promise API) { const filename = join(tmpdir.path, 'append-promise.txt'); diff --git a/test/parallel/test-fs-read-stream-double-close.js b/test/parallel/test-fs-read-stream-double-close.js index 38556e6e644a3d..32117a0a1e9402 100644 --- a/test/parallel/test-fs-read-stream-double-close.js +++ b/test/parallel/test-fs-read-stream-double-close.js @@ -13,7 +13,7 @@ const fs = require('fs'); { const s = fs.createReadStream(__filename); - // this is a private API, but it is worth testing. close calls this + // This is a private API, but it is worth testing. close calls this s.destroy(null, common.mustCall()); s.destroy(null, common.mustCall()); } diff --git a/test/parallel/test-fs-realpath.js b/test/parallel/test-fs-realpath.js index 18b9de471bc3a8..5c1c0cd962a3d5 100644 --- a/test/parallel/test-fs-realpath.js +++ b/test/parallel/test-fs-realpath.js @@ -251,7 +251,7 @@ function test_relative_input_cwd(realpath, realpathSync, callback) { return callback(); } - // we need to calculate the relative path to the tmp dir from cwd + // We need to calculate the relative path to the tmp dir from cwd const entrydir = process.cwd(); const entry = path.relative(entrydir, path.join(`${tmpDir}/cycles/realpath-3a`)); diff --git a/test/parallel/test-fs-sync-fd-leak.js b/test/parallel/test-fs-sync-fd-leak.js index ee2e0355ec7aab..30016e02845298 100644 --- a/test/parallel/test-fs-sync-fd-leak.js +++ b/test/parallel/test-fs-sync-fd-leak.js @@ -27,7 +27,7 @@ const fs = require('fs'); const { internalBinding } = require('internal/test/binding'); const { UV_EBADF } = internalBinding('uv'); -// ensure that (read|write|append)FileSync() closes the file descriptor +// Ensure that (read|write|append)FileSync() closes the file descriptor fs.openSync = function() { return 42; }; diff --git a/test/parallel/test-fs-utimes.js b/test/parallel/test-fs-utimes.js index 92558eef149040..43fbe41dccc249 100644 --- a/test/parallel/test-fs-utimes.js +++ b/test/parallel/test-fs-utimes.js @@ -186,7 +186,7 @@ process.on('exit', () => { const path = `${tmpdir.path}/test-utimes-precision`; fs.writeFileSync(path, ''); -// test Y2K38 for all platforms [except 'arm', 'OpenBSD' and 'SunOS'] +// Test Y2K38 for all platforms [except 'arm', 'OpenBSD' and 'SunOS'] if (!process.arch.includes('arm') && !common.isOpenBSD && !common.isSunOS) { // because 2 ** 31 doesn't look right // eslint-disable-next-line space-infix-ops diff --git a/test/parallel/test-fs-write-stream-change-open.js b/test/parallel/test-fs-write-stream-change-open.js index 8f79e59427e50d..56dbafd656431b 100644 --- a/test/parallel/test-fs-write-stream-change-open.js +++ b/test/parallel/test-fs-write-stream-change-open.js @@ -35,7 +35,7 @@ const stream = fs.WriteStream(file); const _fs_close = fs.close; const _fs_open = fs.open; -// change the fs.open with an identical function after the WriteStream +// Change the fs.open with an identical function after the WriteStream // has pushed it onto its internal action queue, but before it's // returned. This simulates AOP-style extension of the fs lib. fs.open = function() { diff --git a/test/parallel/test-heapdump-inspector.js b/test/parallel/test-heapdump-inspector.js index 963b85ac3a029a..d46be57c914a06 100644 --- a/test/parallel/test-heapdump-inspector.js +++ b/test/parallel/test-heapdump-inspector.js @@ -13,7 +13,7 @@ const snapshotNode = { ] }; -// starts with no JSBindingsConnection (or 1 if coverage enabled). +// Starts with no JSBindingsConnection (or 1 if coverage enabled). { const expected = []; if (process.env.NODE_V8_COVERAGE) { diff --git a/test/parallel/test-http-agent-false.js b/test/parallel/test-http-agent-false.js index 4d92d5e01e03e2..2f4505ef66ef3e 100644 --- a/test/parallel/test-http-agent-false.js +++ b/test/parallel/test-http-agent-false.js @@ -23,7 +23,7 @@ const common = require('../common'); const http = require('http'); -// sending `agent: false` when `port: null` is also passed in (i.e. the result +// Sending `agent: false` when `port: null` is also passed in (i.e. the result // of a `url.parse()` call with the default port used, 80 or 443), should not // result in an assertion error... const opts = { @@ -34,7 +34,7 @@ const opts = { agent: false }; -// we just want an "error" (no local HTTP server on port 80) or "response" +// We just want an "error" (no local HTTP server on port 80) or "response" // to happen (user happens ot have HTTP server running on port 80). // As long as the process doesn't crash from a C++ assertion then we're good. const req = http.request(opts); diff --git a/test/parallel/test-http-agent-no-protocol.js b/test/parallel/test-http-agent-no-protocol.js index b5a144abc93d9e..d1eaf242a51004 100644 --- a/test/parallel/test-http-agent-no-protocol.js +++ b/test/parallel/test-http-agent-no-protocol.js @@ -29,7 +29,7 @@ const server = http.createServer(common.mustCall((req, res) => { })).listen(0, '127.0.0.1', common.mustCall(() => { const opts = url.parse(`http://127.0.0.1:${server.address().port}/`); - // remove the `protocol` field… the `http` module should fall back + // Remove the `protocol` field… the `http` module should fall back // to "http:", as defined by the global, default `http.Agent` instance. opts.agent = new http.Agent(); opts.agent.protocol = null; diff --git a/test/parallel/test-http-client-headers-array.js b/test/parallel/test-http-client-headers-array.js index c637de61c012b5..31ee35a123ccb9 100644 --- a/test/parallel/test-http-client-headers-array.js +++ b/test/parallel/test-http-client-headers-array.js @@ -39,7 +39,7 @@ function execute(options) { }); } -// should be the same except for implicit Host header on the first two +// Should be the same except for implicit Host header on the first two execute({ headers: { 'x-foo': 'boom', 'cookie': 'a=1; b=2; c=3' } }); execute({ headers: { 'x-foo': 'boom', 'cookie': [ 'a=1', 'b=2', 'c=3' ] } }); execute({ headers: [[ 'x-foo', 'boom' ], [ 'cookie', 'a=1; b=2; c=3' ]] }); diff --git a/test/parallel/test-http-conn-reset.js b/test/parallel/test-http-conn-reset.js index 7d0509a89ff68e..fef75b72891e9c 100644 --- a/test/parallel/test-http-conn-reset.js +++ b/test/parallel/test-http-conn-reset.js @@ -31,7 +31,7 @@ const options = { }; process.env.NODE_DEBUG = 'http'; -// start a tcp server that closes incoming connections immediately +// Start a tcp server that closes incoming connections immediately const server = net.createServer(function(client) { client.destroy(); server.close(); diff --git a/test/parallel/test-http-outgoing-message-inheritance.js b/test/parallel/test-http-outgoing-message-inheritance.js index 05a241dc8bda00..9beb4aeff17fab 100644 --- a/test/parallel/test-http-outgoing-message-inheritance.js +++ b/test/parallel/test-http-outgoing-message-inheritance.js @@ -5,7 +5,7 @@ const { OutgoingMessage } = require('http'); const { Writable } = require('stream'); const assert = require('assert'); -// check that OutgoingMessage can be used without a proper Socket +// Check that OutgoingMessage can be used without a proper Socket // Fixes: https://github.com/nodejs/node/issues/14386 // Fixes: https://github.com/nodejs/node/issues/14381 diff --git a/test/parallel/test-http-remove-header-stays-removed.js b/test/parallel/test-http-remove-header-stays-removed.js index 337fcd3becd177..09a44753885d1b 100644 --- a/test/parallel/test-http-remove-header-stays-removed.js +++ b/test/parallel/test-http-remove-header-stays-removed.js @@ -26,7 +26,7 @@ const assert = require('assert'); const http = require('http'); const server = http.createServer(function(request, response) { - // removed headers should stay removed, even if node automatically adds them + // Removed headers should stay removed, even if node automatically adds them // to the output: response.removeHeader('connection'); response.removeHeader('transfer-encoding'); diff --git a/test/parallel/test-http-url.parse-auth-with-header-in-request.js b/test/parallel/test-http-url.parse-auth-with-header-in-request.js index c10f5ed7b0d31b..eb96ac19c172ff 100644 --- a/test/parallel/test-http-url.parse-auth-with-header-in-request.js +++ b/test/parallel/test-http-url.parse-auth-with-header-in-request.js @@ -41,7 +41,7 @@ const server = http.createServer(function(request, response) { server.listen(0, function() { const testURL = url.parse(`http://asdf:qwer@localhost:${this.address().port}`); - // the test here is if you set a specific authorization header in the + // The test here is if you set a specific authorization header in the // request we should not override that with basic auth testURL.headers = { Authorization: 'NoAuthForYOU' diff --git a/test/parallel/test-http2-client-onconnect-errors.js b/test/parallel/test-http2-client-onconnect-errors.js index e72b5f454ba650..ab166c22f0e9de 100644 --- a/test/parallel/test-http2-client-onconnect-errors.js +++ b/test/parallel/test-http2-client-onconnect-errors.js @@ -65,7 +65,7 @@ const tests = specificTests.concat(genericTests); let currentError; -// mock submitRequest because we only care about testing error handling +// Mock submitRequest because we only care about testing error handling Http2Session.prototype.request = () => currentError; const server = http2.createServer(common.mustNotCall()); diff --git a/test/parallel/test-http2-client-setNextStreamID-errors.js b/test/parallel/test-http2-client-setNextStreamID-errors.js index 3fb4728b7d3a1c..39d194e1f51a93 100644 --- a/test/parallel/test-http2-client-setNextStreamID-errors.js +++ b/test/parallel/test-http2-client-setNextStreamID-errors.js @@ -37,7 +37,7 @@ server.listen(0, common.mustCall(() => { } ); - // should throw if something other than number is passed to setNextStreamID + // Should throw if something other than number is passed to setNextStreamID Object.entries(types).forEach(([type, value]) => { if (type === 'number') { return; diff --git a/test/parallel/test-http2-compat-serverresponse-headers-after-destroy.js b/test/parallel/test-http2-compat-serverresponse-headers-after-destroy.js index 206bd1c9d43e06..fc97a70f42d956 100644 --- a/test/parallel/test-http2-compat-serverresponse-headers-after-destroy.js +++ b/test/parallel/test-http2-compat-serverresponse-headers-after-destroy.js @@ -6,7 +6,7 @@ if (!common.hasCrypto) const assert = require('assert'); const h2 = require('http2'); -// makes sure that Http2ServerResponse setHeader & removeHeader, do not throw +// Makes sure that Http2ServerResponse setHeader & removeHeader, do not throw // any errors if the stream was destroyed before headers were sent const server = h2.createServer(); diff --git a/test/parallel/test-http2-compat-socket.js b/test/parallel/test-http2-compat-socket.js index 498677af6ee796..5b61f27bb2b828 100644 --- a/test/parallel/test-http2-compat-socket.js +++ b/test/parallel/test-http2-compat-socket.js @@ -62,7 +62,7 @@ server.on('request', common.mustCall(function(request, response) { }); })); - // properties that do not exist on the proxy are retrieved from the socket + // Properties that do not exist on the proxy are retrieved from the socket assert.ok(request.socket._server); assert.strictEqual(request.socket.connecting, false); diff --git a/test/parallel/test-http2-connect-method.js b/test/parallel/test-http2-connect-method.js index 0ddbc60433cf85..46c5bf9795db69 100644 --- a/test/parallel/test-http2-connect-method.js +++ b/test/parallel/test-http2-connect-method.js @@ -55,7 +55,7 @@ server.listen(0, common.mustCall(() => { proxy.listen(0, () => { const client = http2.connect(`http://localhost:${proxy.address().port}`); - // confirm that :authority is required and :scheme & :path are forbidden + // Confirm that :authority is required and :scheme & :path are forbidden common.expectsError( () => client.request({ [HTTP2_HEADER_METHOD]: 'CONNECT' diff --git a/test/parallel/test-http2-connect.js b/test/parallel/test-http2-connect.js index 252efa1229ad85..b93faf9d938380 100644 --- a/test/parallel/test-http2-connect.js +++ b/test/parallel/test-http2-connect.js @@ -33,7 +33,7 @@ const { connect: netConnect } = require('net'); })); } -// check for session connect callback on already connected socket +// Check for session connect callback on already connected socket { const server = createServer(); server.listen(0, mustCall(() => { diff --git a/test/parallel/test-http2-info-headers-errors.js b/test/parallel/test-http2-info-headers-errors.js index e2cae58466bb82..6540747fd25a5f 100644 --- a/test/parallel/test-http2-info-headers-errors.js +++ b/test/parallel/test-http2-info-headers-errors.js @@ -39,7 +39,7 @@ const tests = specificTests.concat(genericTests); let currentError; -// mock sendHeaders because we only care about testing error handling +// Mock sendHeaders because we only care about testing error handling Http2Stream.prototype.info = () => currentError.ngError; const server = http2.createServer(); diff --git a/test/parallel/test-http2-respond-nghttperrors.js b/test/parallel/test-http2-respond-nghttperrors.js index 5ebd24a65b1b2f..d720ec1fa486f7 100644 --- a/test/parallel/test-http2-respond-nghttperrors.js +++ b/test/parallel/test-http2-respond-nghttperrors.js @@ -40,7 +40,7 @@ const tests = specificTests.concat(genericTests); let currentError; -// mock submitResponse because we only care about testing error handling +// Mock submitResponse because we only care about testing error handling Http2Stream.prototype.respond = () => currentError.ngError; const server = http2.createServer(); diff --git a/test/parallel/test-http2-respond-with-fd-errors.js b/test/parallel/test-http2-respond-with-fd-errors.js index 9dfd95ea5a2c7c..f336d9caac1f8f 100644 --- a/test/parallel/test-http2-respond-with-fd-errors.js +++ b/test/parallel/test-http2-respond-with-fd-errors.js @@ -47,7 +47,7 @@ const tests = specificTests.concat(genericTests); let currentError; -// mock `respond` because we only care about testing error handling +// Mock `respond` because we only care about testing error handling Http2Stream.prototype.respond = () => currentError.ngError; const server = http2.createServer(); diff --git a/test/parallel/test-http2-server-push-stream-errors.js b/test/parallel/test-http2-server-push-stream-errors.js index e489cae439205e..fb6fc11b63f999 100644 --- a/test/parallel/test-http2-server-push-stream-errors.js +++ b/test/parallel/test-http2-server-push-stream-errors.js @@ -64,7 +64,7 @@ const tests = specificTests.concat(genericTests); let currentError; -// mock submitPushPromise because we only care about testing error handling +// Mock submitPushPromise because we only care about testing error handling Http2Stream.prototype.pushPromise = () => currentError.ngError; const server = http2.createServer(); diff --git a/test/parallel/test-https-argument-of-creating.js b/test/parallel/test-https-argument-of-creating.js index 063002840616fc..1154f968d792c3 100644 --- a/test/parallel/test-https-argument-of-creating.js +++ b/test/parallel/test-https-argument-of-creating.js @@ -22,7 +22,7 @@ const dftProtocol = {}; } -// validate that `createServer` can work with the only argument requestListener +// Validate that `createServer` can work with the only argument requestListener { const mustNotCall = common.mustNotCall(); const server = https.createServer(mustNotCall); diff --git a/test/parallel/test-listen-fd-cluster.js b/test/parallel/test-listen-fd-cluster.js index da8abd868300e3..bc81a8da0bc312 100644 --- a/test/parallel/test-listen-fd-cluster.js +++ b/test/parallel/test-listen-fd-cluster.js @@ -47,14 +47,14 @@ process.on('exit', function() { assert.ok(ok); }); -// spawn the parent, and listen for it to tell us the pid of the cluster. +// Spawn the parent, and listen for it to tell us the pid of the cluster. // WARNING: This is an example of listening on some arbitrary FD number // that has already been bound elsewhere in advance. However, binding // server handles to stdio fd's is NOT a good or reliable way to do // concurrency in HTTP servers! Use the cluster module, or if you want // a more low-level approach, use child process IPC manually. test(function(parent, port) { - // now make sure that we can request to the worker, then kill it. + // Now make sure that we can request to the worker, then kill it. http.get({ server: 'localhost', port: port, diff --git a/test/parallel/test-listen-fd-detached-inherit.js b/test/parallel/test-listen-fd-detached-inherit.js index 4feb7dc3ab03dd..e0fc25134cce93 100644 --- a/test/parallel/test-listen-fd-detached-inherit.js +++ b/test/parallel/test-listen-fd-detached-inherit.js @@ -35,7 +35,7 @@ switch (process.argv[2]) { default: return test(); } -// spawn the parent, and listen for it to tell us the pid of the child. +// Spawn the parent, and listen for it to tell us the pid of the child. // WARNING: This is an example of listening on some arbitrary FD number // that has already been bound elsewhere in advance. However, binding // server handles to stdio fd's is NOT a good or reliable way to do @@ -53,7 +53,7 @@ function test() { function next() { console.error('output from parent = %s', json); const child = JSON.parse(json); - // now make sure that we can request to the subprocess, then kill it. + // Now make sure that we can request to the subprocess, then kill it. http.get({ server: 'localhost', port: child.port, diff --git a/test/parallel/test-listen-fd-detached.js b/test/parallel/test-listen-fd-detached.js index 09d7f8b6c1a68c..eec12132a1d6f2 100644 --- a/test/parallel/test-listen-fd-detached.js +++ b/test/parallel/test-listen-fd-detached.js @@ -35,7 +35,7 @@ switch (process.argv[2]) { default: return test(); } -// spawn the parent, and listen for it to tell us the pid of the child. +// Spawn the parent, and listen for it to tell us the pid of the child. // WARNING: This is an example of listening on some arbitrary FD number // that has already been bound elsewhere in advance. However, binding // server handles to stdio fd's is NOT a good or reliable way to do @@ -53,7 +53,7 @@ function test() { function next() { console.error('output from parent = %s', json); const child = JSON.parse(json); - // now make sure that we can request to the subprocess, then kill it. + // Now make sure that we can request to the subprocess, then kill it. http.get({ server: 'localhost', port: child.port, diff --git a/test/parallel/test-listen-fd-server.js b/test/parallel/test-listen-fd-server.js index 7cdba8b405892a..a09a01f219daf1 100644 --- a/test/parallel/test-listen-fd-server.js +++ b/test/parallel/test-listen-fd-server.js @@ -44,7 +44,7 @@ process.on('exit', function() { // concurrency in HTTP servers! Use the cluster module, or if you want // a more low-level approach, use child process IPC manually. test(function(child, port) { - // now make sure that we can request to the subprocess, then kill it. + // Now make sure that we can request to the subprocess, then kill it. http.get({ server: 'localhost', port: port, diff --git a/test/parallel/test-net-pipe-connect-errors.js b/test/parallel/test-net-pipe-connect-errors.js index 8db452669991f0..330203365e7fbe 100644 --- a/test/parallel/test-net-pipe-connect-errors.js +++ b/test/parallel/test-net-pipe-connect-errors.js @@ -32,7 +32,7 @@ const assert = require('assert'); let emptyTxt; if (common.isWindows) { - // on Win, common.PIPE will be a named pipe, so we use an existing empty + // On Win, common.PIPE will be a named pipe, so we use an existing empty // file instead emptyTxt = fixtures.path('empty.txt'); } else { diff --git a/test/parallel/test-net-server-connections.js b/test/parallel/test-net-server-connections.js index 9e1213ada558c3..52b2fe6bf567e3 100644 --- a/test/parallel/test-net-server-connections.js +++ b/test/parallel/test-net-server-connections.js @@ -32,7 +32,7 @@ const expectedWarning = 'Server.connections property is deprecated. ' + common.expectWarning('DeprecationWarning', expectedWarning, 'DEP0020'); -// test that server.connections property is no longer enumerable now that it +// Test that server.connections property is no longer enumerable now that it // has been marked as deprecated assert.strictEqual(Object.keys(server).includes('connections'), false); diff --git a/test/parallel/test-net-socket-setnodelay.js b/test/parallel/test-net-socket-setnodelay.js index be5c8ffc8524dc..55b4c773fa5bf7 100644 --- a/test/parallel/test-net-socket-setnodelay.js +++ b/test/parallel/test-net-socket-setnodelay.js @@ -32,7 +32,7 @@ socket = new net.Socket({ }); falseyValues.forEach((testVal) => socket.setNoDelay(testVal)); -// if a handler doesn't have a setNoDelay function it shouldn't be called. +// If a handler doesn't have a setNoDelay function it shouldn't be called. // In the case below, if it is called an exception will be thrown socket = new net.Socket({ handle: { diff --git a/test/parallel/test-net-stream.js b/test/parallel/test-net-stream.js index 4e7e06bfcf2546..8e996dd58a7ef6 100644 --- a/test/parallel/test-net-stream.js +++ b/test/parallel/test-net-stream.js @@ -27,7 +27,7 @@ const net = require('net'); const s = new net.Stream(); -// test that destroy called on a stream with a server only ever decrements the +// Test that destroy called on a stream with a server only ever decrements the // server connection count once s.server = new net.Server(); diff --git a/test/parallel/test-path-zero-length-strings.js b/test/parallel/test-path-zero-length-strings.js index c1b74c515fccdc..f6516ffff85acb 100644 --- a/test/parallel/test-path-zero-length-strings.js +++ b/test/parallel/test-path-zero-length-strings.js @@ -10,7 +10,7 @@ const assert = require('assert'); const path = require('path'); const pwd = process.cwd(); -// join will internally ignore all the zero-length strings and it will return +// Join will internally ignore all the zero-length strings and it will return // '.' if the joined string is a zero-length string. assert.strictEqual(path.posix.join(''), '.'); assert.strictEqual(path.posix.join('', ''), '.'); @@ -19,7 +19,7 @@ assert.strictEqual(path.win32.join('', ''), '.'); assert.strictEqual(path.join(pwd), pwd); assert.strictEqual(path.join(pwd, ''), pwd); -// normalize will return '.' if the input is a zero-length string +// Normalize will return '.' if the input is a zero-length string assert.strictEqual(path.posix.normalize(''), '.'); assert.strictEqual(path.win32.normalize(''), '.'); assert.strictEqual(path.normalize(pwd), pwd); @@ -28,12 +28,12 @@ assert.strictEqual(path.normalize(pwd), pwd); assert.strictEqual(path.posix.isAbsolute(''), false); assert.strictEqual(path.win32.isAbsolute(''), false); -// resolve, internally ignores all the zero-length strings and returns the +// Resolve, internally ignores all the zero-length strings and returns the // current working directory assert.strictEqual(path.resolve(''), pwd); assert.strictEqual(path.resolve('', ''), pwd); -// relative, internally calls resolve. So, '' is actually the current directory +// Relative, internally calls resolve. So, '' is actually the current directory assert.strictEqual(path.relative('', pwd), ''); assert.strictEqual(path.relative(pwd, ''), ''); assert.strictEqual(path.relative(pwd, pwd), ''); diff --git a/test/parallel/test-process-beforeexit.js b/test/parallel/test-process-beforeexit.js index d197d943a4b07d..215e73dc0650f3 100644 --- a/test/parallel/test-process-beforeexit.js +++ b/test/parallel/test-process-beforeexit.js @@ -46,7 +46,7 @@ function tryListen() { })); } -// test that a function invoked from the beforeExit handler can use a timer +// Test that a function invoked from the beforeExit handler can use a timer // to keep the event loop open, which can use another timer to keep the event // loop open, etc. function tryRepeatedTimer() { diff --git a/test/parallel/test-process-env-allowed-flags.js b/test/parallel/test-process-env-allowed-flags.js index ddd8d894eabcb1..b3d815f66de6da 100644 --- a/test/parallel/test-process-env-allowed-flags.js +++ b/test/parallel/test-process-env-allowed-flags.js @@ -3,7 +3,7 @@ const assert = require('assert'); require('../common'); -// assert legit flags are allowed, and bogus flags are disallowed +// Assert legit flags are allowed, and bogus flags are disallowed { const goodFlags = [ '--perf_basic_prof', diff --git a/test/parallel/test-process-env.js b/test/parallel/test-process-env.js index 81651efbea024d..d146d5c616607a 100644 --- a/test/parallel/test-process-env.js +++ b/test/parallel/test-process-env.js @@ -65,7 +65,7 @@ if (process.argv[2] === 'you-are-the-child') { } -// delete should return true except for non-configurable properties +// Delete should return true except for non-configurable properties // https://github.com/nodejs/node/issues/7960 delete process.env.NON_EXISTING_VARIABLE; assert(delete process.env.NON_EXISTING_VARIABLE); diff --git a/test/parallel/test-process-exit-recursive.js b/test/parallel/test-process-exit-recursive.js index 57f5c2956f8c0d..727aa4abe7232c 100644 --- a/test/parallel/test-process-exit-recursive.js +++ b/test/parallel/test-process-exit-recursive.js @@ -23,14 +23,14 @@ require('../common'); const assert = require('assert'); -// recursively calling .exit() should not overflow the call stack +// Recursively calling .exit() should not overflow the call stack let nexits = 0; process.on('exit', function(code) { assert.strictEqual(nexits++, 0); assert.strictEqual(code, 1); - // now override the exit code of 1 with 0 so that the test passes + // Now override the exit code of 1 with 0 so that the test passes process.exit(0); }); diff --git a/test/parallel/test-process-exit.js b/test/parallel/test-process-exit.js index ac934d4c6818a4..cd605949af51e8 100644 --- a/test/parallel/test-process-exit.js +++ b/test/parallel/test-process-exit.js @@ -23,7 +23,7 @@ require('../common'); const assert = require('assert'); -// calling .exit() from within "exit" should not overflow the call stack +// Calling .exit() from within "exit" should not overflow the call stack let nexits = 0; process.on('exit', function(code) { diff --git a/test/parallel/test-process-release.js b/test/parallel/test-process-release.js index 8b6bca9141beed..874c658c20d8ff 100644 --- a/test/parallel/test-process-release.js +++ b/test/parallel/test-process-release.js @@ -7,7 +7,7 @@ const versionParts = process.versions.node.split('.'); assert.strictEqual(process.release.name, 'node'); -// it's expected that future LTS release lines will have additional +// It's expected that future LTS release lines will have additional // branches in here if (versionParts[0] === '4' && versionParts[1] >= 2) { assert.strictEqual(process.release.lts, 'Argon'); diff --git a/test/parallel/test-readline-interface.js b/test/parallel/test-readline-interface.js index ec553832c42d68..408d70e788095e 100644 --- a/test/parallel/test-readline-interface.js +++ b/test/parallel/test-readline-interface.js @@ -189,7 +189,7 @@ function isWarned(emitter) { rli.close(); } - // sending multiple newlines at once that does not end with a new line + // Sending multiple newlines at once that does not end with a new line { const fi = new FakeInput(); const rli = new readline.Interface( @@ -206,7 +206,7 @@ function isWarned(emitter) { rli.close(); } - // sending multiple newlines at once that does not end with a new(empty) + // Sending multiple newlines at once that does not end with a new(empty) // line and a `end` event { const fi = new FakeInput(); @@ -228,7 +228,7 @@ function isWarned(emitter) { rli.close(); } - // sending multiple newlines at once that does not end with a new line + // Sending multiple newlines at once that does not end with a new line // and a `end` event(last line is) // \r should behave like \n when alone @@ -354,7 +354,7 @@ function isWarned(emitter) { rli.close(); } - // constructor throws if completer is not a function or undefined + // Constructor throws if completer is not a function or undefined { const fi = new FakeInput(); common.expectsError(function() { @@ -979,7 +979,7 @@ function isWarned(emitter) { assert.strictEqual(isWarned(process.stdout._events), false); } - // can create a new readline Interface with a null output argument + // Can create a new readline Interface with a null output argument { const fi = new FakeInput(); const rli = new readline.Interface( @@ -1037,7 +1037,7 @@ function isWarned(emitter) { const crlfDelay = Infinity; [ true, false ].forEach(function(terminal) { - // sending multiple newlines at once that does not end with a new line + // Sending multiple newlines at once that does not end with a new line // and a `end` event(last line is) // \r\n should emit one line event, not two diff --git a/test/parallel/test-repl-save-load.js b/test/parallel/test-repl-save-load.js index 7ca0e9c0164056..2767c0f02629be 100644 --- a/test/parallel/test-repl-save-load.js +++ b/test/parallel/test-repl-save-load.js @@ -97,7 +97,7 @@ let loadFile = join(tmpdir.path, 'file.does.not.exist'); // should not break putIn.write = function(data) { - // make sure I get a failed to load message and not some crazy error + // Make sure I get a failed to load message and not some crazy error assert.strictEqual(data, `Failed to load:${loadFile}\n`); // eat me to avoid work putIn.write = () => {}; @@ -121,7 +121,7 @@ const invalidFileName = join(tmpdir.path, '\0\0\0\0\0'); // should not break putIn.write = function(data) { - // make sure I get a failed to save message and not some other error + // Make sure I get a failed to save message and not some other error assert.strictEqual(data, `Failed to save:${invalidFileName}\n`); // reset to no-op putIn.write = () => {}; diff --git a/test/parallel/test-repl-tab-complete.js b/test/parallel/test-repl-tab-complete.js index 378072ecb8c3e7..9edebe90365939 100644 --- a/test/parallel/test-repl-tab-complete.js +++ b/test/parallel/test-repl-tab-complete.js @@ -207,7 +207,7 @@ testMe.complete(' ', common.mustCall(function(error, data) { clearTimeout(spaceTimeout); })); -// tab completion should pick up the global "toString" object, and +// Tab completion should pick up the global "toString" object, and // any other properties up the "global" object's prototype chain testMe.complete('toSt', common.mustCall(function(error, data) { assert.deepStrictEqual(data, [['toString'], 'toSt']); diff --git a/test/parallel/test-repl-unexpected-token-recoverable.js b/test/parallel/test-repl-unexpected-token-recoverable.js index 652c17d8f8ac59..c4b3a08e969000 100644 --- a/test/parallel/test-repl-unexpected-token-recoverable.js +++ b/test/parallel/test-repl-unexpected-token-recoverable.js @@ -6,7 +6,7 @@ require('../common'); const assert = require('assert'); const spawn = require('child_process').spawn; -// use -i to force node into interactive mode, despite stdout not being a TTY +// Use -i to force node into interactive mode, despite stdout not being a TTY const args = [ '-i' ]; const child = spawn(process.execPath, args); diff --git a/test/parallel/test-repl.js b/test/parallel/test-repl.js index f8261dedd98974..98f47a03aaf008 100644 --- a/test/parallel/test-repl.js +++ b/test/parallel/test-repl.js @@ -204,13 +204,13 @@ const errorTests = [ send: 'JSON.parse(\'{"valid": "json"}\');', expect: '{ valid: \'json\' }' }, - // invalid input to JSON.parse error is special case of syntax error, + // Invalid input to JSON.parse error is special case of syntax error, // should throw { send: 'JSON.parse(\'{invalid: \\\'json\\\'}\');', expect: [/^SyntaxError: /, ''] }, - // end of input to JSON.parse error is special case of syntax error, + // End of input to JSON.parse error is special case of syntax error, // should throw { send: 'JSON.parse(\'066\');', @@ -380,19 +380,19 @@ const errorTests = [ send: 'var path = 42; path', expect: '42' }, - // this makes sure that we don't print `undefined` when we actually print + // This makes sure that we don't print `undefined` when we actually print // the error message { send: '.invalid_repl_command', expect: 'Invalid REPL keyword' }, - // this makes sure that we don't crash when we use an inherited property as + // This makes sure that we don't crash when we use an inherited property as // a REPL command { send: '.toString', expect: 'Invalid REPL keyword' }, - // fail when we are not inside a String and a line continuation is used + // Fail when we are not inside a String and a line continuation is used { send: '[] \\', expect: [ @@ -421,7 +421,7 @@ const errorTests = [ send: '\'the \\\n fourth\t\t\\\n eye \'', expect: '... ... \'the fourth\\t\\t eye \'' }, - // more than one multiline strings also should preserve whitespace chars + // More than one multiline strings also should preserve whitespace chars { send: '\'the \\\n fourth\' + \'\t\t\\\n eye \'', expect: '... ... \'the fourth\\t\\t eye \'' @@ -431,7 +431,7 @@ const errorTests = [ send: '\'\\\n.break', expect: '... ' + prompt_unix }, - // using REPL command "help" within a string literal should still work + // Using REPL command "help" within a string literal should still work { send: '\'thefourth\\\n.help\neye\'', expect: [ @@ -450,7 +450,7 @@ const errorTests = [ send: '\n\r\n\r\n', expect: '' }, - // empty lines in the string literals should not affect the string + // Empty lines in the string literals should not affect the string { send: '\'the\\\n\\\nfourtheye\'\n', expect: '... ... \'thefourtheye\'' @@ -460,14 +460,14 @@ const errorTests = [ send: '/(.)(.)(.)(.)(.)(.)(.)(.)(.)/.test(\'123456789\')\n', expect: 'true' }, - // the following test's result depends on the RegExp's match from the above + // The following test's result depends on the RegExp's match from the above { send: 'RegExp.$1\nRegExp.$2\nRegExp.$3\nRegExp.$4\nRegExp.$5\n' + 'RegExp.$6\nRegExp.$7\nRegExp.$8\nRegExp.$9\n', expect: ['\'1\'', '\'2\'', '\'3\'', '\'4\'', '\'5\'', '\'6\'', '\'7\'', '\'8\'', '\'9\''] }, - // regression tests for https://github.com/nodejs/node/issues/2749 + // Regression tests for https://github.com/nodejs/node/issues/2749 { send: 'function x() {\nreturn \'\\n\';\n }', expect: '... ... undefined' @@ -476,7 +476,7 @@ const errorTests = [ send: 'function x() {\nreturn \'\\\\\';\n }', expect: '... ... undefined' }, - // regression tests for https://github.com/nodejs/node/issues/3421 + // Regression tests for https://github.com/nodejs/node/issues/3421 { send: 'function x() {\n//\'\n }', expect: '... ... undefined' diff --git a/test/parallel/test-stream-readable-hwm-0.js b/test/parallel/test-stream-readable-hwm-0.js index ecbc197d48208f..b66782b7713765 100644 --- a/test/parallel/test-stream-readable-hwm-0.js +++ b/test/parallel/test-stream-readable-hwm-0.js @@ -16,7 +16,7 @@ const r = new Readable({ }); let pushedNull = false; -// this will trigger read(0) but must only be called after push(null) +// This will trigger read(0) but must only be called after push(null) // because the we haven't pushed any data r.on('readable', common.mustCall(() => { assert.strictEqual(r.read(), null); diff --git a/test/parallel/test-stream-readable-reading-readingMore.js b/test/parallel/test-stream-readable-reading-readingMore.js index 71c07d7b062c18..74468ed68afc8e 100644 --- a/test/parallel/test-stream-readable-reading-readingMore.js +++ b/test/parallel/test-stream-readable-reading-readingMore.js @@ -143,7 +143,7 @@ const Readable = require('stream').Readable; readable.on('end', common.mustCall(onStreamEnd)); readable.push('pushed'); - // we are still not flowing, we will be resuming in the next tick + // We are still not flowing, we will be resuming in the next tick assert.strictEqual(state.flowing, false); // wait for nextTick, so the readableListener flag resets diff --git a/test/parallel/test-stream-unshift-read-race.js b/test/parallel/test-stream-unshift-read-race.js index f2977b285f4db3..69f966e05f4f36 100644 --- a/test/parallel/test-stream-unshift-read-race.js +++ b/test/parallel/test-stream-unshift-read-race.js @@ -106,7 +106,7 @@ r.on('readable', function() { }); w.on('finish', common.mustCall(function() { - // each chunk should start with 1234, and then be asfdasdfasdf... + // Each chunk should start with 1234, and then be asfdasdfasdf... // The first got pulled out before the first unshift('1234'), so it's // lacking that piece. assert.strictEqual(written[0], 'asdfasdfas'); diff --git a/test/parallel/test-stream-writableState-uncorked-bufferedRequestCount.js b/test/parallel/test-stream-writableState-uncorked-bufferedRequestCount.js index 86dd7aed1b1403..ca5d3dfb0f02bc 100644 --- a/test/parallel/test-stream-writableState-uncorked-bufferedRequestCount.js +++ b/test/parallel/test-stream-writableState-uncorked-bufferedRequestCount.js @@ -35,7 +35,7 @@ assert.strictEqual(writable._writableState.bufferedRequestCount, 1); process.nextTick(uncork); -// the second chunk is buffered, because we uncork at the end of tick +// The second chunk is buffered, because we uncork at the end of tick writable.write('second chunk'); assert.strictEqual(writable._writableState.corked, 1); assert.strictEqual(writable._writableState.bufferedRequestCount, 2); diff --git a/test/parallel/test-stream2-basic.js b/test/parallel/test-stream2-basic.js index 0083077fc2d649..f1e4fb02b4436c 100644 --- a/test/parallel/test-stream2-basic.js +++ b/test/parallel/test-stream2-basic.js @@ -40,7 +40,7 @@ class TestReader extends R { n = Math.max(n, 0); const toRead = Math.min(n, max); if (toRead === 0) { - // simulate the read buffer filling up with some more bytes some time + // Simulate the read buffer filling up with some more bytes some time // in the future. setTimeout(() => { this._pos = 0; diff --git a/test/parallel/test-stream2-push.js b/test/parallel/test-stream2-push.js index 33645df8a5541c..9d209c18b9f489 100644 --- a/test/parallel/test-stream2-push.js +++ b/test/parallel/test-stream2-push.js @@ -27,7 +27,7 @@ const { Readable, Writable } = require('stream'); const EE = require('events').EventEmitter; -// a mock thing a bit like the net.Socket/tcp_wrap.handle interaction +// A mock thing a bit like the net.Socket/tcp_wrap.handle interaction const stream = new Readable({ highWaterMark: 16, diff --git a/test/parallel/test-stream2-readable-empty-buffer-no-eof.js b/test/parallel/test-stream2-readable-empty-buffer-no-eof.js index 219a902c71fd56..f1e74ad949c590 100644 --- a/test/parallel/test-stream2-readable-empty-buffer-no-eof.js +++ b/test/parallel/test-stream2-readable-empty-buffer-no-eof.js @@ -31,7 +31,7 @@ test2(); function test1() { const r = new Readable(); - // should not end when we get a Buffer.alloc(0) or '' as the _read + // Should not end when we get a Buffer.alloc(0) or '' as the _read // result that just means that there is *temporarily* no data, but to // go ahead and try again later. // diff --git a/test/parallel/test-string-decoder-end.js b/test/parallel/test-string-decoder-end.js index c686b19b713d73..3dd445e6c7149b 100644 --- a/test/parallel/test-string-decoder-end.js +++ b/test/parallel/test-string-decoder-end.js @@ -20,7 +20,7 @@ // USE OR OTHER DEALINGS IN THE SOFTWARE. 'use strict'; -// verify that the string decoder works getting 1 byte at a time, +// Verify that the string decoder works getting 1 byte at a time, // the whole buffer at once, and that both match the .toString(enc) // result of the entire buffer. diff --git a/test/parallel/test-string-decoder.js b/test/parallel/test-string-decoder.js index c043795fc6ee5e..aaffa131cd8246 100644 --- a/test/parallel/test-string-decoder.js +++ b/test/parallel/test-string-decoder.js @@ -201,7 +201,7 @@ common.expectsError( } ); -// test verifies that StringDecoder will correctly decode the given input +// Test verifies that StringDecoder will correctly decode the given input // buffer with the given encoding to the expected output. It will attempt all // possible ways to write() the input buffer, see writeSequences(). The // singleSequence allows for easy debugging of a specific sequence which is diff --git a/test/parallel/test-timers-api-refs.js b/test/parallel/test-timers-api-refs.js index c062369444b1e0..3c55a05ac4c20a 100644 --- a/test/parallel/test-timers-api-refs.js +++ b/test/parallel/test-timers-api-refs.js @@ -2,7 +2,7 @@ const common = require('../common'); const timers = require('timers'); -// delete global APIs to make sure they're not relied on by the internal timers +// Delete global APIs to make sure they're not relied on by the internal timers // code delete global.setTimeout; delete global.clearTimeout; diff --git a/test/parallel/test-timers-ordering.js b/test/parallel/test-timers-ordering.js index e163ea55bf2dd8..1f2809ab4e1831 100644 --- a/test/parallel/test-timers-ordering.js +++ b/test/parallel/test-timers-ordering.js @@ -38,7 +38,7 @@ function f(i) { assert.strictEqual(i, last_i + 1, `order is broken: ${i} != ${last_i} + 1`); last_i = i; - // check that this iteration is fired at least 1ms later than the previous + // Check that this iteration is fired at least 1ms later than the previous const now = getLibuvNow(); assert(now >= last_ts + 1, `current ts ${now} < prev ts ${last_ts} + 1`); diff --git a/test/parallel/test-tls-securepair-fiftharg.js b/test/parallel/test-tls-securepair-fiftharg.js index 185dc43d941ca6..0651f98c6d780d 100644 --- a/test/parallel/test-tls-securepair-fiftharg.js +++ b/test/parallel/test-tls-securepair-fiftharg.js @@ -19,7 +19,7 @@ const pair = tls.createSecurePair(sslcontext, true, false, false, { }) }); -// captured traffic from browser's request to https://www.google.com +// Captured traffic from browser's request to https://www.google.com const sslHello = fixtures.readSync('google_ssl_hello.bin'); pair.encrypted.write(sslHello); diff --git a/test/parallel/test-tls-socket-snicallback-without-server.js b/test/parallel/test-tls-socket-snicallback-without-server.js index 9d30bc17b96b65..3ef28b95702552 100644 --- a/test/parallel/test-tls-socket-snicallback-without-server.js +++ b/test/parallel/test-tls-socket-snicallback-without-server.js @@ -20,7 +20,7 @@ new tls.TLSSocket(serverSide, { }) }); -// captured traffic from browser's request to https://www.google.com +// Captured traffic from browser's request to https://www.google.com const sslHello = fixtures.readSync('google_ssl_hello.bin'); clientSide.write(sslHello); diff --git a/test/parallel/test-url-relative.js b/test/parallel/test-url-relative.js index d8532fcfee0ed6..6bead6a30d7007 100644 --- a/test/parallel/test-url-relative.js +++ b/test/parallel/test-url-relative.js @@ -234,7 +234,7 @@ const relativeTests2 = [ // may change to http:///s//a/../../../g ['../../../../g', bases[4], 'http:///g'], - // from Dan Connelly's tests in http://www.w3.org/2000/10/swap/uripath.py + // From Dan Connelly's tests in http://www.w3.org/2000/10/swap/uripath.py ['bar:abc', 'foo:xyz', 'bar:abc'], ['../abc', 'http://example/x/y/z', 'http://example/x/abc'], ['http://example/x/abc', 'http://example2/x/y/z', 'http://example/x/abc'], diff --git a/test/parallel/test-v8-coverage.js b/test/parallel/test-v8-coverage.js index 191835fe0f5af9..69a8286eed886d 100644 --- a/test/parallel/test-v8-coverage.js +++ b/test/parallel/test-v8-coverage.js @@ -16,7 +16,7 @@ function nextdir() { return `cov_${++dirc}`; } -// outputs coverage when event loop is drained, with no async logic. +// Outputs coverage when event loop is drained, with no async logic. { const coverageDirectory = path.join(tmpdir.path, nextdir()); const output = spawnSync(process.execPath, [ @@ -46,7 +46,7 @@ function nextdir() { assert.strictEqual(fixtureCoverage.functions[1].ranges[1].count, 0); } -// outputs coverage when process.kill(process.pid, "SIGINT"); exits process. +// Outputs coverage when process.kill(process.pid, "SIGINT"); exits process. { const coverageDirectory = path.join(tmpdir.path, nextdir()); const output = spawnSync(process.execPath, [ diff --git a/test/parallel/test-whatwg-encoding-textdecoder.js b/test/parallel/test-whatwg-encoding-textdecoder.js index e1d8575a644490..55afd34a02b11e 100644 --- a/test/parallel/test-whatwg-encoding-textdecoder.js +++ b/test/parallel/test-whatwg-encoding-textdecoder.js @@ -177,7 +177,7 @@ function testDecodeSample(encoding, string, bytes) { string); } -// z (ASCII U+007A), cent (Latin-1 U+00A2), CJK water (BMP U+6C34), +// `z` (ASCII U+007A), cent (Latin-1 U+00A2), CJK water (BMP U+6C34), // G-Clef (non-BMP U+1D11E), PUA (BMP U+F8FF), PUA (non-BMP U+10FFFD) // byte-swapped BOM (non-character U+FFFE) const sample = 'z\xA2\u6C34\uD834\uDD1E\uF8FF\uDBFF\uDFFD\uFFFE'; diff --git a/test/parallel/test-zlib-from-concatenated-gzip.js b/test/parallel/test-zlib-from-concatenated-gzip.js index c73a29e649765b..fea8ab6de2870a 100644 --- a/test/parallel/test-zlib-from-concatenated-gzip.js +++ b/test/parallel/test-zlib-from-concatenated-gzip.js @@ -39,7 +39,7 @@ zlib.unzip(Buffer.concat([ assert.strictEqual(result.toString(), abc); })); -// files that have the "right" magic bytes for starting a new gzip member +// Files that have the "right" magic bytes for starting a new gzip member // in the middle of themselves, even if they are part of a single // regularly compressed member const pmmFileZlib = fixtures.path('pseudo-multimember-gzip.z'); @@ -59,7 +59,7 @@ fs.createReadStream(pmmFileGz) assert.deepStrictEqual(Buffer.concat(pmmResultBuffers), pmmExpected); })); -// test that the next gzip member can wrap around the input buffer boundary +// Test that the next gzip member can wrap around the input buffer boundary [0, 1, 2, 3, 4, defEncoded.length].forEach((offset) => { const resultBuffers = []; diff --git a/test/parallel/test-zlib-from-gzip-with-trailing-garbage.js b/test/parallel/test-zlib-from-gzip-with-trailing-garbage.js index 48d9e441429eeb..c9eeb29f937c06 100644 --- a/test/parallel/test-zlib-from-gzip-with-trailing-garbage.js +++ b/test/parallel/test-zlib-from-gzip-with-trailing-garbage.js @@ -23,7 +23,7 @@ zlib.gunzip(data, common.mustCall((err, result) => { ); })); -// if the trailing garbage happens to look like a gzip header, it should +// If the trailing garbage happens to look like a gzip header, it should // throw an error. data = Buffer.concat([ zlib.gzipSync('abc'), diff --git a/test/parallel/test-zlib-from-gzip.js b/test/parallel/test-zlib-from-gzip.js index 99c3f1757e05d8..277df3c4cc2bc3 100644 --- a/test/parallel/test-zlib-from-gzip.js +++ b/test/parallel/test-zlib-from-gzip.js @@ -20,7 +20,7 @@ // USE OR OTHER DEALINGS IN THE SOFTWARE. 'use strict'; -// test unzipping a file that was created with a non-node gzip lib, +// Test unzipping a file that was created with a non-node gzip lib, // piped in as fast as possible. const common = require('../common'); diff --git a/test/pummel/test-https-ci-reneg-attack.js b/test/pummel/test-https-ci-reneg-attack.js index 9411d24e077097..fad8cd992dd35d 100644 --- a/test/pummel/test-https-ci-reneg-attack.js +++ b/test/pummel/test-https-ci-reneg-attack.js @@ -72,7 +72,7 @@ function test(next) { child.stdout.resume(); child.stderr.resume(); - // count handshakes, start the attack after the initial handshake is done + // Count handshakes, start the attack after the initial handshake is done let handshakes = 0; let renegs = 0; diff --git a/test/pummel/test-timers.js b/test/pummel/test-timers.js index a6766b7a33c11d..6b761f455de20e 100644 --- a/test/pummel/test-timers.js +++ b/test/pummel/test-timers.js @@ -103,7 +103,7 @@ const interval4 = setInterval(function() { }, 0); -// we should be able to clearTimeout multiple times without breakage. +// We should be able to clearTimeout multiple times without breakage. let expectedTimeouts = 3; function t() { diff --git a/test/pummel/test-tls-ci-reneg-attack.js b/test/pummel/test-tls-ci-reneg-attack.js index 528ebe4516c71d..3509dcfd43f853 100644 --- a/test/pummel/test-tls-ci-reneg-attack.js +++ b/test/pummel/test-tls-ci-reneg-attack.js @@ -70,7 +70,7 @@ function test(next) { child.stdout.resume(); child.stderr.resume(); - // count handshakes, start the attack after the initial handshake is done + // Count handshakes, start the attack after the initial handshake is done let handshakes = 0; let renegs = 0; diff --git a/test/sequential/test-cli-syntax.js b/test/sequential/test-cli-syntax.js index 35cc78258dad01..74e8c9fa91755f 100644 --- a/test/sequential/test-cli-syntax.js +++ b/test/sequential/test-cli-syntax.js @@ -112,7 +112,7 @@ syntaxArgs.forEach(function(args) { assert.strictEqual(c.status, 0); }); -// should throw if code piped from stdin with --check has bad syntax +// Should throw if code piped from stdin with --check has bad syntax // loop each possible option, `-c` or `--check` syntaxArgs.forEach(function(args) { const stdin = 'var foo bar;'; diff --git a/test/sequential/test-http-max-http-headers.js b/test/sequential/test-http-max-http-headers.js index 1dece8beed2f68..64358e8140f9a3 100644 --- a/test/sequential/test-http-max-http-headers.js +++ b/test/sequential/test-http-max-http-headers.js @@ -27,8 +27,8 @@ function finished(client, callback) { } function fillHeaders(headers, currentSize, valid = false) { - // llhttp counts actual header name/value sizes, excluding the whitespace and - // stripped chars. + // `llhttp` counts actual header name/value sizes, excluding the whitespace + // and stripped chars. if (getOptionValue('--http-parser') === 'llhttp') { // OK, Content-Length, 0, X-CRASH, aaa... headers += 'a'.repeat(MAX - currentSize); diff --git a/test/sequential/test-init.js b/test/sequential/test-init.js index 1b1b09ee833191..a86a1fd045f48c 100644 --- a/test/sequential/test-init.js +++ b/test/sequential/test-init.js @@ -43,7 +43,7 @@ function test(file, expected) { } { - // change CWD as we do this test so it's not dependent on current CWD + // Change CWD as we do this test so it's not dependent on current CWD // being in the test folder process.chdir(__dirname); test('test-init', 'Loaded successfully!'); @@ -57,7 +57,7 @@ function test(file, expected) { } { - // ensures that `node fs` does not mistakenly load the native 'fs' module + // Ensures that `node fs` does not mistakenly load the native 'fs' module // instead of the desired file and that the fs module loads as // expected in node process.chdir(fixtures.path('test-init-native')); diff --git a/test/sequential/test-inspector.js b/test/sequential/test-inspector.js index 00fdb000e9e251..237b65193fa86e 100644 --- a/test/sequential/test-inspector.js +++ b/test/sequential/test-inspector.js @@ -171,7 +171,7 @@ async function testCommandLineAPI(session) { const printBModulePath = require.resolve('../fixtures/printB.js'); const printBModuleStr = JSON.stringify(printBModulePath); - // we can use `require` outside of a callframe with require in scope + // We can use `require` outside of a callframe with require in scope let result = await session.send( { 'method': 'Runtime.evaluate', 'params': { @@ -182,7 +182,7 @@ async function testCommandLineAPI(session) { checkException(result); assert.strictEqual(result.result.value, true); - // the global require has the same properties as a normal `require` + // The global require has the same properties as a normal `require` result = await session.send( { 'method': 'Runtime.evaluate', 'params': { @@ -273,7 +273,7 @@ async function testCommandLineAPI(session) { parentsEqual: true, parentId: '' }); - // the `require` in the module shadows the command line API's `require` + // The `require` in the module shadows the command line API's `require` result = await session.send( { 'method': 'Debugger.evaluateOnCallFrame', 'params': { diff --git a/tools/eslint-rules/required-modules.js b/tools/eslint-rules/required-modules.js index 948c46c036d99d..208e13ffe74fc2 100644 --- a/tools/eslint-rules/required-modules.js +++ b/tools/eslint-rules/required-modules.js @@ -17,7 +17,7 @@ module.exports = function(context) { const foundModules = []; - // if no modules are required we don't need to check the CallExpressions + // If no modules are required we don't need to check the CallExpressions if (requiredModules.length === 0) { return {}; }