benchmark,doc,lib,test: capitalize comments

This updates a lot of comments.

PR-URL: https://github.com/nodejs/node/pull/26223
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com>
Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com>
This commit is contained in:
Ruben Bridgewater 2019-01-21 01:22:27 +01:00
parent 7b674697d8
commit 9edce1e12a
No known key found for this signature in database
GPG Key ID: F07496B3EB3C1762
200 changed files with 346 additions and 347 deletions

View File

@ -60,9 +60,9 @@ module.exports = {
'brace-style': ['error', '1tbs', { allowSingleLine: true }],
'capitalized-comments': ['error', 'always', {
line: {
// Ignore all lines that have less characters than 50 and all lines that
// Ignore all lines that have less characters than 40 and all lines that
// start with something that looks like a variable name or code.
ignorePattern: '^.{0,50}$|^ [a-z]+ ?[0-9A-Z_.(/=:[#-]',
ignorePattern: '^.{0,40}$|^ [a-z]+ ?[0-9A-Z_.(/=:[#-]|^ std',
ignoreInlineComments: true,
ignoreConsecutiveComments: true,
},

View File

@ -28,7 +28,7 @@ function CLI(usage, settings) {
}
let currentOptional = null;
let mode = 'both'; // possible states are: [both, option, item]
let mode = 'both'; // Possible states are: [both, option, item]
for (const arg of process.argv.slice(2)) {
if (arg === '--') {
@ -59,7 +59,7 @@ function CLI(usage, settings) {
this.optional[currentOptional] = arg;
}
// the next value can be either an option or an item
// The next value can be either an option or an item
mode = 'both';
} else if (['both', 'item'].includes(mode)) {
// item arguments

View File

@ -15,7 +15,7 @@ function main({ api, cipher, type, len, writes }) {
cipher = 'AES192';
if (api === 'stream' && /^v0\.[0-8]\./.test(process.version)) {
console.error('Crypto streams not available until v0.10');
// use the legacy, just so that we can compare them.
// Use the legacy, just so that we can compare them.
api = 'legacy';
}

View File

@ -16,7 +16,7 @@ const bench = common.createBenchmark(main, {
function main({ api, type, len, out, writes, algo }) {
if (api === 'stream' && /^v0\.[0-8]\./.test(process.version)) {
console.error('Crypto streams not available until v0.10');
// use the legacy, just so that we can compare them.
// Use the legacy, just so that we can compare them.
api = 'legacy';
}
@ -54,7 +54,7 @@ function legacyWrite(algo, message, encoding, writes, len, outEnc) {
h.update(message, encoding);
var res = h.digest(outEnc);
// include buffer creation costs for older versions
// Include buffer creation costs for older versions
if (outEnc === 'buffer' && typeof res === 'string')
res = Buffer.from(res, 'binary');
}

View File

@ -15,7 +15,7 @@ const bench = common.createBenchmark(main, {
function main({ api, type, len, algo, writes }) {
if (api === 'stream' && /^v0\.[0-8]\./.test(process.version)) {
console.error('Crypto streams not available until v0.10');
// use the legacy, just so that we can compare them.
// Use the legacy, just so that we can compare them.
api = 'legacy';
}

View File

@ -1,5 +1,5 @@
'use strict';
// throughput benchmark in signing and verifying
// Throughput benchmark in signing and verifying
const common = require('../common.js');
const crypto = require('crypto');
const fs = require('fs');

View File

@ -1,5 +1,5 @@
'use strict';
// throughput benchmark in signing and verifying
// Throughput benchmark in signing and verifying
const common = require('../common.js');
const crypto = require('crypto');
const fs = require('fs');

View File

@ -1,4 +1,4 @@
// test the throughput of the fs.WriteStream class.
// Test the throughput of the fs.WriteStream class.
'use strict';
const path = require('path');

View File

@ -1,4 +1,4 @@
// test the throughput of the fs.WriteStream class.
// Test the throughput of the fs.WriteStream class.
'use strict';
const path = require('path');

View File

@ -5,7 +5,7 @@
const common = require('../common.js');
const util = require('util');
// if there are --dur=N and --len=N args, then
// If there are --dur=N and --len=N args, then
// run the function with those settings.
// if not, then queue up a bunch of child processes.
const bench = common.createBenchmark(main, {
@ -36,7 +36,7 @@ function main({ dur, len, type }) {
if (err)
fail(err, 'connect');
// the meat of the benchmark is right here:
// The meat of the benchmark is right here:
bench.start();
var bytes = 0;

View File

@ -5,7 +5,7 @@
const common = require('../common.js');
const util = require('util');
// if there are --dur=N and --len=N args, then
// If there are --dur=N and --len=N args, then
// run the function with those settings.
// if not, then queue up a bunch of child processes.
const bench = common.createBenchmark(main, {

View File

@ -122,7 +122,7 @@ function main({ dur, len, type }) {
clientHandle.readStart();
// the meat of the benchmark is right here:
// The meat of the benchmark is right here:
bench.start();
setTimeout(() => {

View File

@ -1070,7 +1070,7 @@ const subprocess = spawn(
);
setTimeout(() => {
subprocess.kill(); // does not terminate the node process in the shell
subprocess.kill(); // Does not terminate the node process in the shell
}, 2000);
```

View File

@ -128,7 +128,7 @@ if (cluster.isMaster) {
// Anything can happen now! Be very careful!
try {
// make sure we close down within 30 seconds
// Make sure we close down within 30 seconds
const killtimer = setTimeout(() => {
process.exit(1);
}, 30000);
@ -148,7 +148,7 @@ if (cluster.isMaster) {
res.setHeader('content-type', 'text/plain');
res.end('Oops, there was a problem!\n');
} catch (er2) {
// oh well, not much we can do at this point.
// Oh well, not much we can do at this point.
console.error(`Error sending 500! ${er2.stack}`);
}
});
@ -240,13 +240,13 @@ perhaps we would like to have a separate domain to use for each request.
That is possible via explicit binding.
```js
// create a top-level domain for the server
// Create a top-level domain for the server
const domain = require('domain');
const http = require('http');
const serverDomain = domain.create();
serverDomain.run(() => {
// server is created in the scope of serverDomain
// Server is created in the scope of serverDomain
http.createServer((req, res) => {
// Req and res are also created in the scope of serverDomain
// however, we'd prefer to have a separate domain for each request.
@ -373,7 +373,7 @@ const d = domain.create();
function readSomeFile(filename, cb) {
fs.readFile(filename, 'utf8', d.intercept((data) => {
// note, the first argument is never passed to the
// Note, the first argument is never passed to the
// callback since it is assumed to be the 'Error' argument
// and thus intercepted by the domain.

View File

@ -101,7 +101,7 @@ http.get({
hostname: 'localhost',
port: 80,
path: '/',
agent: false // create a new agent just for this one request
agent: false // Create a new agent just for this one request
}, (res) => {
// Do stuff with response
});

View File

@ -2598,7 +2598,7 @@ const server = createSecureServer(
).listen(4443);
function onRequest(req, res) {
// detects if it is a HTTPS request or HTTP/2
// Detects if it is a HTTPS request or HTTP/2
const { socket: { alpnProtocol } } = req.httpVersion === '2.0' ?
req.stream.session : req;
res.writeHead(200, { 'content-type': 'application/json' });
@ -3371,9 +3371,9 @@ const obs = new PerformanceObserver((items) => {
const entry = items.getEntries()[0];
console.log(entry.entryType); // prints 'http2'
if (entry.name === 'Http2Session') {
// entry contains statistics about the Http2Session
// Entry contains statistics about the Http2Session
} else if (entry.name === 'Http2Stream') {
// entry contains statistics about the Http2Stream
// Entry contains statistics about the Http2Stream
}
});
obs.observe({ entryTypes: ['http2'] });

View File

@ -167,7 +167,7 @@ session.connect();
session.post('Profiler.enable', () => {
session.post('Profiler.start', () => {
// invoke business logic under measurement here...
// Invoke business logic under measurement here...
// some time later...
session.post('Profiler.stop', (err, { profile }) => {

View File

@ -109,7 +109,7 @@ Any other input values will be coerced to empty strings.
```js
querystring.stringify({ foo: 'bar', baz: ['qux', 'quux'], corge: '' });
// returns 'foo=bar&baz=qux&baz=quux&corge='
// Returns 'foo=bar&baz=qux&baz=quux&corge='
querystring.stringify({ foo: 'bar', baz: 'qux' }, ';', ':');
// returns 'foo:bar;baz:qux'

View File

@ -135,7 +135,7 @@ const server = http.createServer((req, res) => {
req.on('end', () => {
try {
const data = JSON.parse(body);
// write back something interesting to the user:
// Write back something interesting to the user:
res.write(typeof data);
res.end();
} catch (er) {
@ -413,7 +413,7 @@ Calling the [`stream.write()`][stream-write] method after calling
[`stream.end()`][stream-end] will raise an error.
```js
// write 'hello, ' and then end with 'world!'
// Write 'hello, ' and then end with 'world!'
const fs = require('fs');
const file = fs.createWriteStream('example.txt');
file.write('hello, ');
@ -684,7 +684,7 @@ pass.unpipe(writable);
pass.on('data', (chunk) => { console.log(chunk.toString()); });
pass.write('ok'); // will not emit 'data'
pass.resume(); // must be called to make stream emit 'data'
pass.resume(); // Must be called to make stream emit 'data'
```
While `readable.readableFlowing` is `false`, data may be accumulating
@ -1211,7 +1211,7 @@ function parseHeader(stream, callback) {
const remaining = split.join('\n\n');
const buf = Buffer.from(remaining, 'utf8');
stream.removeListener('error', callback);
// remove the 'readable' listener before unshifting
// Remove the 'readable' listener before unshifting
stream.removeListener('readable', onReadable);
if (buf.length)
stream.unshift(buf);

View File

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

View File

@ -131,7 +131,7 @@ Object.defineProperty(Duplex.prototype, 'destroyed', {
return;
}
// backward compatibility, the user is explicitly
// Backward compatibility, the user is explicitly
// managing destroyed
this._readableState.destroyed = value;
this._writableState.destroyed = value;

View File

@ -134,7 +134,7 @@ function ReadableState(options, stream, isDuplex) {
// The number of writers that are awaiting a drain event in .pipe()s
this.awaitDrain = 0;
// if true, a maybeReadMore has been scheduled
// If true, a maybeReadMore has been scheduled
this.readingMore = false;
this.decoder = null;
@ -189,7 +189,7 @@ Object.defineProperty(Readable.prototype, 'destroyed', {
return;
}
// backward compatibility, the user is explicitly
// Backward compatibility, the user is explicitly
// managing destroyed
this._readableState.destroyed = value;
}
@ -669,7 +669,7 @@ Readable.prototype.pipe = function(dest, pipeOpts) {
var cleanedUp = false;
function cleanup() {
debug('cleanup');
// cleanup event handlers once the pipe is broken
// Cleanup event handlers once the pipe is broken
dest.removeListener('close', onclose);
dest.removeListener('finish', onfinish);
dest.removeListener('drain', ondrain);
@ -745,7 +745,7 @@ Readable.prototype.pipe = function(dest, pipeOpts) {
// tell the dest that it's being piped to
dest.emit('pipe', src);
// start the flow if it hasn't been started already.
// Start the flow if it hasn't been started already.
if (!state.flowing) {
debug('pipe resume');
src.resume();
@ -772,13 +772,13 @@ Readable.prototype.unpipe = function(dest) {
var state = this._readableState;
var unpipeInfo = { hasUnpiped: false };
// if we're not piping anywhere, then do nothing.
// If we're not piping anywhere, then do nothing.
if (state.pipesCount === 0)
return this;
// just one destination. most common case.
// Just one destination. most common case.
if (state.pipesCount === 1) {
// passed in one, but it's not the right one.
// Passed in one, but it's not the right one.
if (dest && dest !== state.pipes)
return this;
@ -824,7 +824,7 @@ Readable.prototype.unpipe = function(dest) {
return this;
};
// set up data events if they are asked for
// Set up data events if they are asked for
// Ensure readable listeners eventually get something
Readable.prototype.on = function(ev, fn) {
const res = Stream.prototype.on.call(this, ev, fn);
@ -893,7 +893,7 @@ function updateReadableListening(self) {
state.readableListening = self.listenerCount('readable') > 0;
if (state.resumeScheduled && !state.paused) {
// flowing needs to be set to true now, otherwise
// Flowing needs to be set to true now, otherwise
// the upcoming resume will not flow.
state.flowing = true;
@ -914,7 +914,7 @@ Readable.prototype.resume = function() {
var state = this._readableState;
if (!state.flowing) {
debug('resume');
// we flow only if there is no one listening
// We flow only if there is no one listening
// for readable, but we still have to call
// resume()
state.flowing = !state.readableListening;
@ -984,7 +984,7 @@ Readable.prototype.wrap = function(stream) {
if (state.decoder)
chunk = state.decoder.write(chunk);
// don't skip over falsy values in objectMode
// Don't skip over falsy values in objectMode
if (state.objectMode && (chunk === null || chunk === undefined))
return;
else if (!state.objectMode && (!chunk || !chunk.length))

View File

@ -69,7 +69,7 @@ function WritableState(options, stream, isDuplex) {
if (isDuplex)
this.objectMode = this.objectMode || !!options.writableObjectMode;
// the point at which write() starts returning false
// The point at which write() starts returning false
// Note: 0 is a valid value, means that we always return false if
// the entire buffer is not flushed immediately on write()
this.highWaterMark = getHighWaterMark(this, options, 'writableHighWaterMark',
@ -82,7 +82,7 @@ function WritableState(options, stream, isDuplex) {
this.needDrain = false;
// at the start of calling end()
this.ending = false;
// when end() has been called, and returned
// When end() has been called, and returned
this.ended = false;
// when 'finish' is emitted
this.finished = false;
@ -123,7 +123,7 @@ function WritableState(options, stream, isDuplex) {
// end up in an overlapped onwrite situation.
this.bufferProcessing = false;
// the callback that's passed to _write(chunk,cb)
// 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)
@ -135,7 +135,7 @@ function WritableState(options, stream, isDuplex) {
this.bufferedRequest = null;
this.lastBufferedRequest = null;
// number of pending user-supplied write callbacks
// Number of pending user-supplied write callbacks
// this must be 0 before 'finish' can be emitted
this.pendingcb = 0;
@ -155,7 +155,7 @@ function WritableState(options, stream, isDuplex) {
// count buffered requests
this.bufferedRequestCount = 0;
// allocate the first CorkedRequest, there is always
// Allocate the first CorkedRequest, there is always
// one allocated and free to use, and we maintain at most two
var corkReq = { next: null, entry: null, finish: undefined };
corkReq.finish = onCorkedFinish.bind(undefined, corkReq, this);
@ -423,13 +423,13 @@ function onwriteError(stream, state, sync, er, cb) {
// Defer the callback if we are being called synchronously
// to avoid piling up things on the stack
process.nextTick(cb, er);
// this can emit finish, and it will always happen
// This can emit finish, and it will always happen
// after error
process.nextTick(finishMaybe, stream, state);
stream._writableState.errorEmitted = true;
errorOrDestroy(stream, er);
} else {
// the caller expect this to happen before if
// The caller expect this to happen before if
// it is async
cb(er);
stream._writableState.errorEmitted = true;
@ -545,7 +545,7 @@ function clearBuffer(stream, state) {
doWrite(stream, state, false, len, chunk, encoding, cb);
entry = entry.next;
state.bufferedRequestCount--;
// if we didn't call the onwrite immediately, then
// If we didn't call the onwrite immediately, then
// it means that we need to wait until it does.
// also, that means that the chunk and cb are currently
// being processed, so move the buffer counter past them.
@ -703,7 +703,7 @@ Object.defineProperty(Writable.prototype, 'destroyed', {
return;
}
// backward compatibility, the user is explicitly
// Backward compatibility, the user is explicitly
// managing destroyed
this._writableState.destroyed = value;
}

View File

@ -570,7 +570,7 @@ TLSSocket.prototype._init = function(socket, wrap) {
}
if (options.ALPNProtocols) {
// keep reference in secureContext not to be GC-ed
// Keep reference in secureContext not to be GC-ed
ssl._secureContext.alpnBuffer = options.ALPNProtocols;
ssl.setALPNProtocols(ssl._secureContext.alpnBuffer);
}

View File

@ -254,7 +254,7 @@ Socket.prototype.bind = function(port_, address_ /* , callback */) {
exclusive = false;
}
// defaulting address for bind to all interfaces
// Defaulting address for bind to all interfaces
if (!address) {
if (this.type === 'udp4')
address = '0.0.0.0';

View File

@ -298,7 +298,7 @@ Domain.prototype.add = function(ee) {
if (ee.domain)
ee.domain.remove(ee);
// check for circular Domain->Domain links.
// Check for circular Domain->Domain links.
// This causes bad insanity!
//
// For example:

View File

@ -374,7 +374,7 @@ EventEmitter.prototype.removeAllListeners =
if (events === undefined)
return this;
// not listening for removeListener, no need to emit
// Not listening for removeListener, no need to emit
if (events.removeListener === undefined) {
if (arguments.length === 0) {
this._events = Object.create(null);

View File

@ -383,7 +383,7 @@ function readFileSync(path, options) {
fs.closeSync(fd);
if (size === 0) {
// data was collected into the buffers list.
// Data was collected into the buffers list.
buffer = Buffer.concat(buffers, pos);
} else if (pos < size) {
buffer = buffer.slice(0, pos);
@ -649,7 +649,7 @@ function truncateSync(path, len) {
if (len === undefined) {
len = 0;
}
// allow error to be thrown, but still close fd.
// Allow error to be thrown, but still close fd.
const fd = fs.openSync(path, 'r+');
let ret;
@ -1484,7 +1484,7 @@ function realpathSync(p, options) {
pos = result + 1;
}
// continue if not a symlink, break if a pipe/socket
// Continue if not a symlink, break if a pipe/socket
if (knownHard[base] || (cache && cache.get(base) === base)) {
if (isFileType(statValues, S_IFIFO) ||
isFileType(statValues, S_IFSOCK)) {
@ -1630,7 +1630,7 @@ function realpath(p, options, callback) {
pos = result + 1;
}
// continue if not a symlink, break if a pipe/socket
// Continue if not a symlink, break if a pipe/socket
if (knownHard[base]) {
if (isFileType(statValues, S_IFIFO) ||
isFileType(statValues, S_IFSOCK)) {
@ -1645,7 +1645,7 @@ function realpath(p, options, callback) {
function gotStat(err, stats) {
if (err) return callback(err);
// if not a symlink, skip to the next path part
// If not a symlink, skip to the next path part
if (!stats.isSymbolicLink()) {
knownHard[base] = true;
return process.nextTick(LOOP);

View File

@ -99,7 +99,7 @@ const handleConversion = {
// if the socket was created by net.Server
if (socket.server) {
// the worker should keep track of the socket
// The worker should keep track of the socket
message.key = socket.server._connectionKey;
var firstTime = !this.channel.sockets.send[message.key];
@ -384,15 +384,15 @@ ChildProcess.prototype.spawn = function(options) {
continue;
}
// stream is already cloned and piped, so close
// The stream is already cloned and piped, thus close it.
if (stream.type === 'wrap') {
stream.handle.close();
continue;
}
if (stream.handle) {
// when i === 0 - we're dealing with stdin
// (which is the only one writable pipe)
// When i === 0 - we're dealing with stdin
// (which is the only one writable pipe).
stream.socket = createSocket(this.pid !== 0 ?
stream.handle : null, i > 0);

View File

@ -47,7 +47,7 @@ cluster._setupWorker = function() {
}
};
// obj is a net#Server or a dgram#Socket object.
// `obj` is a net#Server or a dgram#Socket object.
cluster._getServer = function(obj, options, cb) {
let address = options.address;

View File

@ -358,7 +358,7 @@ Console.prototype.trace = function trace(...args) {
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
this.warn(...args); // The arguments will be formatted in warn() again
}
};

View File

@ -23,7 +23,7 @@ function readFileAfterRead(err, bytesRead) {
else
context.read();
} else {
// unknown size, just read until we don't get bytes.
// Unknown size, just read until we don't get bytes.
context.buffers.push(context.buffer.slice(0, bytesRead));
context.read();
}

View File

@ -153,7 +153,7 @@ ReadStream.prototype._read = function(n) {
else
toRead = Math.min(this.end - this.bytesRead + 1, toRead);
// already read everything we were supposed to read!
// Already read everything we were supposed to read!
// treat as EOF.
if (toRead <= 0)
return this.push(null);
@ -372,7 +372,7 @@ WriteStream.prototype.close = function(cb) {
this.on('finish', this.destroy.bind(this));
}
// we use end() instead of destroy() because of
// We use end() instead of destroy() because of
// https://github.com/nodejs/node/issues/2006
this.end();
};

View File

@ -1734,7 +1734,7 @@ class Http2Stream extends Duplex {
return !!(this[kState].flags & STREAM_FLAGS_HEADERS_SENT);
}
// true if the Http2Stream was aborted abnormally.
// True if the Http2Stream was aborted abnormally.
get aborted() {
return !!(this[kState].flags & STREAM_FLAGS_ABORTED);
}
@ -2242,7 +2242,7 @@ class ServerHttp2Stream extends Http2Stream {
this[kAuthority] = headers[HTTP2_HEADER_AUTHORITY];
}
// true if the remote peer accepts push streams
// True if the remote peer accepts push streams
get pushAllowed() {
return !this.destroyed &&
!this.closed &&
@ -2603,7 +2603,7 @@ function sessionOnError(error) {
// When the session times out on the server, try emitting a timeout event.
// If no handler is registered, destroy the session.
function sessionOnTimeout() {
// if destroyed or closed already, do nothing
// If destroyed or closed already, do nothing
if (this.destroyed || this.closed)
return;
const server = this[kServer];

View File

@ -237,7 +237,7 @@ function tryPackage(requestPath, exts, isMain) {
// Set to an empty Map to reset.
const realpathCache = new Map();
// check if the file exists and is not a directory
// Check if the file exists and is not a directory
// if using --preserve-symlinks and isMain is false,
// keep symlinks intact, otherwise resolve to the
// absolute realpath.
@ -914,7 +914,7 @@ Module._initPaths = function() {
modulePaths = paths;
// clone as a shallow copy, for introspection.
// Clone as a shallow copy, for introspection.
Module.globalPaths = modulePaths.slice(0);
};

View File

@ -262,7 +262,7 @@ function buildAllowedFlags() {
constructor(...args) {
super(...args);
// the super constructor consumes `add`, but
// The super constructor consumes `add`, but
// disallow any future adds.
this.add = () => this;
}

View File

@ -31,7 +31,7 @@ function readAndResolve(iter) {
}
function onReadable(iter) {
// we wait for the next tick, because it might
// We wait for the next tick, because it might
// emit an error with process.nextTick
process.nextTick(readAndResolve, iter);
}
@ -58,7 +58,7 @@ const ReadableStreamAsyncIteratorPrototype = Object.setPrototypeOf({
},
next() {
// if we have detected an error in the meanwhile
// If we have detected an error in the meanwhile
// reject straight away
const error = this[kError];
if (error !== null) {
@ -95,7 +95,7 @@ const ReadableStreamAsyncIteratorPrototype = Object.setPrototypeOf({
if (lastPromise) {
promise = new Promise(wrapForNext(lastPromise, this));
} else {
// fast path needed to support multiple this.push()
// Fast path needed to support multiple this.push()
// without triggering the next() queue
const data = this[kStream].read();
if (data !== null) {
@ -160,7 +160,7 @@ const createReadableStreamAsyncIterator = (stream) => {
finished(stream, (err) => {
if (err && err.code !== 'ERR_STREAM_PREMATURE_CLOSE') {
const reject = iterator[kLastReject];
// reject if we are waiting for data in the Promise
// Reject if we are waiting for data in the Promise
// returned by next() and store the error
if (reject !== null) {
iterator[kLastPromise] = null;

View File

@ -50,7 +50,7 @@ Stream.prototype.pipe = function(dest, options) {
if (typeof dest.destroy === 'function') dest.destroy();
}
// don't leave dangling pipes when there are errors.
// Don't leave dangling pipes when there are errors.
function onerror(er) {
cleanup();
if (EE.listenerCount(this, 'error') === 0) {
@ -61,7 +61,7 @@ Stream.prototype.pipe = function(dest, options) {
source.on('error', onerror);
dest.on('error', onerror);
// remove all the event listeners that were added.
// Remove all the event listeners that were added.
function cleanup() {
source.removeListener('data', ondata);
dest.removeListener('drain', ondrain);

View File

@ -62,7 +62,7 @@ function Timeout(callback, after, args, isRepeat) {
'\nTimeout duration was set to 1.',
'TimeoutOverflowWarning');
}
after = 1; // schedule on next tick, follows browser behavior
after = 1; // Schedule on next tick, follows browser behavior
}
this._idleTimeout = after;

View File

@ -1102,7 +1102,7 @@ defineIDLClass(URLSearchParams.prototype, 'URLSearchParams', {
const key = list[i];
const value = list[i + 1];
callback.call(thisArg, value, key, this);
// in case the URL object's `search` is updated
// In case the URL object's `search` is updated
list = this[searchParams];
i += 2;
}
@ -1369,7 +1369,7 @@ function pathToFileURL(filepath) {
const outURL = new URL('file://');
if (resolved.includes('%'))
resolved = resolved.replace(percentRegEx, '%25');
// in posix, "/" is a valid character in paths
// In posix, "/" is a valid character in paths
if (!isWindows && resolved.includes('\\'))
resolved = resolved.replace(backslashRegEx, '%5C');
if (resolved.includes('\n'))

View File

@ -299,7 +299,7 @@ function Socket(options) {
}
}
// shut down the socket when we're finished with it.
// Shut down the socket when we're finished with it.
this.on('end', onReadableStreamEnd);
initSocketHandle(this);
@ -311,7 +311,7 @@ function Socket(options) {
// buffer. if not, then this will happen when we connect
if (this._handle && options.readable !== false) {
if (options.pauseOnCreate) {
// stop the handle from reading and pause the stream
// Stop the handle from reading and pause the stream
this._handle.reading = false;
this._handle.readStop();
this.readableFlowing = false;
@ -374,7 +374,7 @@ function afterShutdown(status) {
this.callback();
// callback may come after call to destroy.
// Callback may come after call to destroy.
if (self.destroyed)
return;
@ -1044,7 +1044,7 @@ function afterConnect(status, handle, req, readable, writable) {
self.emit('connect');
self.emit('ready');
// start the first read, or get an immediate EOF.
// Start the first read, or get an immediate EOF.
// this doesn't actually consume any bytes, because len=0.
if (readable && !self.isPaused())
self.read(0);

View File

@ -62,7 +62,7 @@ const unhexTable = [
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 // ... 255
];
// a safe fast alternative to decodeURIComponent
// A safe fast alternative to decodeURIComponent
function unescapeBuffer(s, decodeSpaces) {
var out = Buffer.allocUnsafe(s.length);
var index = 0;

View File

@ -183,7 +183,7 @@ function Interface(input, output, completer, terminal) {
function onkeypress(s, key) {
self._ttyWrite(s, key);
if (key && key.sequence) {
// if the key.sequence is half of a surrogate pair
// If the key.sequence is half of a surrogate pair
// (>= 0xd800 and <= 0xdfff), refresh the line so
// the character is displayed appropriately.
const ch = key.sequence.codePointAt(0);
@ -321,10 +321,10 @@ Interface.prototype._writeToOutput = function _writeToOutput(stringToWrite) {
Interface.prototype._addHistory = function() {
if (this.line.length === 0) return '';
// if the history is disabled then return the line
// If the history is disabled then return the line
if (this.historySize === 0) return this.line;
// if the trimmed line is empty then return the line
// If the trimmed line is empty then return the line
if (this.line.trim().length === 0) return this.line;
if (this.history.length === 0 || this.history[0] !== this.line) {
@ -471,7 +471,7 @@ Interface.prototype._insertString = function(c) {
this._writeToOutput(c);
}
// a hack to get the line refreshed if it's needed
// A hack to get the line refreshed if it's needed
this._moveCursor(0);
}
};

View File

@ -234,7 +234,7 @@ function insert(item, refed, start) {
function TimersList(expiry, msecs) {
this._idleNext = this; // Create the list with the linkedlist properties to
this._idlePrev = this; // prevent any unnecessary hidden class changes.
this._idlePrev = this; // Prevent any unnecessary hidden class changes.
this.expiry = expiry;
this.id = timerListId++;
this.msecs = msecs;
@ -410,7 +410,7 @@ exports.unenroll = util.deprecate(unenroll,
function enroll(item, msecs) {
msecs = validateTimerDuration(msecs, 'msecs');
// if this item was already in a list somewhere
// If this item was already in a list somewhere
// then we should unenroll it from that
if (item._idleNext) unenroll(item);

View File

@ -345,14 +345,14 @@ Url.prototype.parse = function parse(url, parseQueryString, slashesDenoteHost) {
// pull out port.
this.parseHost();
// we've indicated that there is a hostname,
// We've indicated that there is a hostname,
// so even if it's empty, it has to be present.
if (typeof this.hostname !== 'string')
this.hostname = '';
var hostname = this.hostname;
// if hostname begins with [ and ends with ]
// If hostname begins with [ and ends with ]
// assume that it's an IPv6 address.
var ipv6Hostname = hostname.charCodeAt(0) === CHAR_LEFT_SQUARE_BRACKET &&
hostname.charCodeAt(hostname.length - 1) === CHAR_RIGHT_SQUARE_BRACKET;
@ -527,9 +527,9 @@ function autoEscapeStr(rest) {
return escaped;
}
// format a parsed object into a url string
// Format a parsed object into a url string
function urlFormat(urlObject, options) {
// ensure it's an object, and not a string url.
// Ensure it's an object, and not a string url.
// If it's an object, this is a no-op.
// this way, you can call urlParse() on strings
// to clean up potentially wonky urls.
@ -678,7 +678,7 @@ Url.prototype.resolveObject = function resolveObject(relative) {
result[tkey] = this[tkey];
}
// hash is always overridden, no matter what.
// Hash is always overridden, no matter what.
// even href="" will remove it.
result.hash = relative.hash;
@ -688,9 +688,9 @@ Url.prototype.resolveObject = function resolveObject(relative) {
return result;
}
// hrefs like //foo/bar always cut to the protocol.
// Hrefs like //foo/bar always cut to the protocol.
if (relative.slashes && !relative.protocol) {
// take everything except the protocol from relative
// Take everything except the protocol from relative
var rkeys = Object.keys(relative);
for (var rk = 0; rk < rkeys.length; rk++) {
var rkey = rkeys[rk];
@ -709,7 +709,7 @@ Url.prototype.resolveObject = function resolveObject(relative) {
}
if (relative.protocol && relative.protocol !== result.protocol) {
// if it's a known url protocol, then changing
// If it's a known url protocol, then changing
// the protocol does weird things
// first, if it's not file:, then we MUST have a host,
// and if there was a path
@ -770,7 +770,7 @@ Url.prototype.resolveObject = function resolveObject(relative) {
var noLeadingSlashes = result.protocol &&
!slashedProtocol.has(result.protocol);
// if the url is a non-slashed url, then relative
// If the url is a non-slashed url, then relative
// links like ../.. should be able
// to crawl up to the hostname, as well. This is strange.
// result.protocol has already been set by now.

View File

@ -143,7 +143,7 @@ function formatWithOptions(inspectOptions, ...args) {
str += first.slice(lastPos, i);
lastPos = i + 1;
continue;
default: // any other character is not a correct placeholder
default: // Any other character is not a correct placeholder
continue;
}
if (lastPos !== i - 1) {

View File

@ -45,7 +45,7 @@ if (process.argv[2] === 'child') {
let state = 'initial';
// parse output that is formatted like this:
// Parse output that is formatted like this:
// uv loop at [0x559b65ed5770] has active handles
// [0x7f2de0018430] timer

View File

@ -10,7 +10,7 @@ const assert = require('assert');
const tmpdir = require('../../common/tmpdir');
tmpdir.refresh();
// make a path that is more than 260 chars long.
// Make a path that is more than 260 chars long.
// Any given folder cannot have a name longer than 260 characters,
// so create 10 nested folders each with 30 character long names.
let addonDestinationDir = path.resolve(tmpdir.path);

View File

@ -39,7 +39,7 @@ const server = https.createServer(serverOptions, (req, res) => {
port: server.address().port,
path: '/test',
clientCertEngine: engine, // engine will provide key+cert
rejectUnauthorized: false, // prevent failing on self-signed certificates
rejectUnauthorized: false, // Prevent failing on self-signed certificates
headers: {}
};

View File

@ -30,7 +30,7 @@ switch (arg) {
return;
}
// this part should run only for the master test
// This part should run only for the master test
assert.ok(!arg);
{
// console.log should stay until this test's flakiness is solved

View File

@ -17,7 +17,7 @@ p.then(function afterResolution(val) {
return val;
});
// init hooks after chained promise is created
// Init hooks after chained promise is created
const hooks = initHooks();
hooks._allowNoInit = true;
hooks.enable();

View File

@ -236,7 +236,7 @@ function platformTimeout(ms) {
ms = multipliers.two * ms;
if (isAIX)
return multipliers.two * ms; // default localhost speed is slower on AIX
return multipliers.two * ms; // Default localhost speed is slower on AIX
if (process.arch !== 'arm')
return ms;

View File

@ -85,7 +85,7 @@ if (process.argv[2] !== 'child') {
// Handle the death of workers
worker.on('exit', function(code, signal) {
// don't consider this the true death if the worker
// Don't consider this the true death if the worker
// has finished successfully
// or if the exit code is 0
if (worker.isDone || code === 0) {
@ -219,7 +219,7 @@ if (process.argv[2] === 'child') {
});
listenSocket.on('message', function(buf, rinfo) {
// receive udp messages only sent from parent
// Receive udp messages only sent from parent
if (rinfo.address !== bindAddress) return;
console.error('[CHILD] %s received %s from %j',

View File

@ -31,7 +31,7 @@ const dnsPromises = require('dns').promises;
);
}
// rrtype is undefined, it's same as resolve4
// Setting rrtype to undefined should work like resolve4.
{
(async function() {
const rrtype = undefined;

View File

@ -45,7 +45,7 @@ assert.strictEqual(test_array.TestHasElement(array, array.length + 1), false);
assert(test_array.NewWithLength(0) instanceof Array);
assert(test_array.NewWithLength(1) instanceof Array);
// check max allowed length for an array 2^32 -1
// Check max allowed length for an array 2^32 -1
assert(test_array.NewWithLength(4294967295) instanceof Array);
{

View File

@ -38,7 +38,7 @@ assert.strictEqual(externalResult[0], 0);
assert.strictEqual(externalResult[1], 1);
assert.strictEqual(externalResult[2], 2);
// validate creation of all kinds of TypedArrays
// Validate creation of all kinds of TypedArrays
const buffer = new ArrayBuffer(128);
const arrayTypes = [ Int8Array, Uint8Array, Uint8ClampedArray, Int16Array,
Uint16Array, Int32Array, Uint32Array, Float32Array,

View File

@ -16,7 +16,7 @@ const BYE = 'bye';
if (cluster.isMaster) {
const worker1 = cluster.fork();
// verify that Windows doesn't support this scenario
// Verify that Windows doesn't support this scenario
worker1.on('error', (err) => {
if (err.code === 'ENOTSUP') throw err;
});

View File

@ -29,7 +29,7 @@ function serialFork() {
return new Promise((res) => {
const worker = cluster.fork();
worker.on('error', (err) => assert.fail(err));
// no common.mustCall since 1 out of 3 should fail
// No common.mustCall since 1 out of 3 should fail
worker.on('online', () => {
worker.on('message', common.mustCall((message) => {
ports.push(message.debugPort);
@ -50,7 +50,7 @@ function serialFork() {
if (cluster.isMaster) {
cluster.on('online', common.mustCall((worker) => worker.send('dbgport'), 2));
// block one of the ports with a listening socket
// Block one of the ports with a listening socket
const server = net.createServer();
server.listen(clashPort, common.localhostIPv4, common.mustCall(() => {
// try to fork 3 workers No.2 should fail

View File

@ -90,7 +90,7 @@ common.expectsError(() => b.write('', 2048), outOfBoundsError);
// throw when writing to negative offset
common.expectsError(() => b.write('a', -1), outOfBoundsError);
// throw when writing past bounds from the pool
// Throw when writing past bounds from the pool
common.expectsError(() => b.write('a', 2048), outOfBoundsError);
// throw when writing to negative offset
@ -290,7 +290,7 @@ Buffer.alloc(1).write('', 1, 0);
assert.strictEqual((Buffer.from('Man')).toString('base64'), 'TWFu');
{
// test that regular and URL-safe base64 both work
// Test that regular and URL-safe base64 both work
const expected = [0xff, 0xff, 0xbe, 0xff, 0xef, 0xbf, 0xfb, 0xef, 0xff];
assert.deepStrictEqual(Buffer.from('//++/++/++//', 'base64'),
Buffer.from(expected));
@ -319,7 +319,7 @@ assert.strictEqual((Buffer.from('Man')).toString('base64'), 'TWFu');
assert.strictEqual(quote.length, bytesWritten);
assert.strictEqual(quote, b.toString('ascii', 0, quote.length));
// check that the base64 decoder ignores whitespace
// Check that the base64 decoder ignores whitespace
const expectedWhite = `${expected.slice(0, 60)} \n` +
`${expected.slice(60, 120)} \n` +
`${expected.slice(120, 180)} \n` +
@ -418,7 +418,7 @@ assert.strictEqual(Buffer.from('KioqKioqKioqKioqKioqKioqKio',
'base64').toString(),
'*'.repeat(20));
// handle padding graciously, multiple-of-4 or not
// Handle padding graciously, multiple-of-4 or not
assert.strictEqual(
Buffer.from('72INjkR5fchcxk9+VgdGPFJDxUBFR5/rMFsghgxADiw==', 'base64').length,
32
@ -762,7 +762,7 @@ assert.strictEqual(x.inspect(), '<Buffer 81 a3 66 6f 6f a3 62 61 72>');
// Call .fill() first, stops valgrind warning about uninitialized memory reads.
Buffer.allocUnsafe(3.3).fill().toString();
// throws bad argument error in commit 43cb4ec
// Throws bad argument error in commit 43cb4ec
Buffer.alloc(3.3).fill().toString();
assert.strictEqual(Buffer.allocUnsafe(3.3).length, 3);
assert.strictEqual(Buffer.from({ length: 3.3 }).length, 3);
@ -808,7 +808,7 @@ common.expectsError(
outOfRangeError
);
// ensure negative values can't get past offset
// Ensure negative values can't get past offset
common.expectsError(
() => Buffer.allocUnsafe(8).writeFloatLE(0.0, -1),
outOfRangeError

View File

@ -74,7 +74,7 @@ assert.strictEqual(Buffer.byteLength('∑éllö wørl∂!', 'utf-8'), 19);
assert.strictEqual(Buffer.byteLength('κλμνξο', 'utf8'), 12);
assert.strictEqual(Buffer.byteLength('挵挶挷挸挹', 'utf-8'), 15);
assert.strictEqual(Buffer.byteLength('𠝹𠱓𠱸', 'UTF8'), 12);
// without an encoding, utf8 should be assumed
// Without an encoding, utf8 should be assumed
assert.strictEqual(Buffer.byteLength('hey there'), 9);
assert.strictEqual(Buffer.byteLength('𠱸挶νξ#xx :)'), 17);
assert.strictEqual(Buffer.byteLength('hello world', ''), 11);

View File

@ -37,7 +37,7 @@ let cntr = 0;
}
{
// copy c into b, without specifying sourceEnd
// Copy c into b, without specifying sourceEnd
b.fill(++cntr);
c.fill(++cntr);
const copied = c.copy(b, 0, 0);
@ -48,7 +48,7 @@ let cntr = 0;
}
{
// copy c into b, without specifying sourceStart
// Copy c into b, without specifying sourceStart
b.fill(++cntr);
c.fill(++cntr);
const copied = c.copy(b, 0);
@ -135,7 +135,7 @@ common.expectsError(
// When sourceStart is greater than sourceEnd, zero copied
assert.strictEqual(b.copy(c, 0, 100, 10), 0);
// when targetStart > targetLength, zero copied
// When targetStart > targetLength, zero copied
assert.strictEqual(b.copy(c, 512, 0, 10), 0);
// Test that the `target` can be a Uint8Array.

View File

@ -287,7 +287,7 @@ for (let lengthIndex = 0; lengthIndex < lengths.length; lengthIndex++) {
);
});
// test truncation of Number arguments to uint8
// Test truncation of Number arguments to uint8
{
const buf = Buffer.from('this is a test');
assert.ok(buf.includes(0x6973));

View File

@ -175,7 +175,7 @@ assert.strictEqual(
);
// test optional offset with passed encoding
// Test optional offset with passed encoding
assert.strictEqual(Buffer.from('aaaa0').indexOf('30', 'hex'), 4);
assert.strictEqual(Buffer.from('aaaa00a').indexOf('3030', 'hex'), 4);
@ -581,7 +581,7 @@ assert.strictEqual(reallyLong.lastIndexOf(pattern), 3932160);
pattern = reallyLong.slice(0, 2000000); // first 2/5ths.
assert.strictEqual(reallyLong.lastIndexOf(pattern), 0);
// test truncation of Number arguments to uint8
// Test truncation of Number arguments to uint8
{
const buf = Buffer.from('this is a test');
assert.strictEqual(buf.indexOf(0x6973), 3);

View File

@ -21,7 +21,7 @@ read(buf, 'readDoubleLE', [1], -6.966010051009108e+144);
read(buf, 'readFloatBE', [1], -1.6691549692541768e+37);
read(buf, 'readFloatLE', [1], -7861303808);
// testing basic functionality of readInt8()
// Testing basic functionality of readInt8()
read(buf, 'readInt8', [1], -3);
// Testing basic functionality of readInt16BE() and readInt16LE()
@ -36,7 +36,7 @@ read(buf, 'readInt32LE', [1], -806729475);
read(buf, 'readIntBE', [1, 1], -3);
read(buf, 'readIntLE', [2, 1], 0x48);
// testing basic functionality of readUInt8()
// Testing basic functionality of readUInt8()
read(buf, 'readUInt8', [1], 0xfd);
// Testing basic functionality of readUInt16BE() and readUInt16LE()

View File

@ -39,7 +39,7 @@ try {
assert.strictEqual(e.name, 'RangeError');
}
// should work with number-coercible values
// Should work with number-coercible values
assert.strictEqual(SlowBuffer('6').length, 6);
assert.strictEqual(SlowBuffer(true).length, 1);

View File

@ -11,13 +11,13 @@ assert.strictEqual(rangeBuffer.toString('ascii', +Infinity), '');
assert.strictEqual(rangeBuffer.toString('ascii', 3.14, 3), '');
assert.strictEqual(rangeBuffer.toString('ascii', 'Infinity', 3), '');
// if end <= 0, empty string will be returned
// If end <= 0, empty string will be returned
assert.strictEqual(rangeBuffer.toString('ascii', 1, 0), '');
assert.strictEqual(rangeBuffer.toString('ascii', 1, -1.2), '');
assert.strictEqual(rangeBuffer.toString('ascii', 1, -100), '');
assert.strictEqual(rangeBuffer.toString('ascii', 1, -Infinity), '');
// if start < 0, start will be taken as zero
// If start < 0, start will be taken as zero
assert.strictEqual(rangeBuffer.toString('ascii', -1, 3), 'abc');
assert.strictEqual(rangeBuffer.toString('ascii', -1.99, 3), 'abc');
assert.strictEqual(rangeBuffer.toString('ascii', -Infinity, 3), 'abc');
@ -78,12 +78,12 @@ assert.strictEqual(rangeBuffer.toString('ascii', 0, '-1.99'), '');
assert.strictEqual(rangeBuffer.toString('ascii', 0, 1.99), 'a');
assert.strictEqual(rangeBuffer.toString('ascii', 0, true), 'a');
// try toString() with a object as a encoding
// Try toString() with an object as an encoding
assert.strictEqual(rangeBuffer.toString({ toString: function() {
return 'ascii';
} }), 'abc');
// try toString() with 0 and null as the encoding
// Try toString() with 0 and null as the encoding
common.expectsError(() => {
rangeBuffer.toString(0, 1, 2);
}, {

View File

@ -71,7 +71,7 @@ if (process.argv[2] === 'child') {
let childFlag = false;
let parentFlag = false;
// when calling .disconnect the event should emit
// When calling .disconnect the event should emit
// and the disconnected flag should be true.
child.on('disconnect', common.mustCall(function() {
parentFlag = child.connected;

View File

@ -35,7 +35,7 @@ if (process.argv[2] === 'child') {
console.error(`[${id}] got socket ${m}`);
// will call .end('end') or .write('write');
// Will call .end('end') or .write('write');
socket[m](m);
socket.resume();

View File

@ -50,7 +50,7 @@ if (process.argv[2] === 'pipe') {
});
} else {
// testcase | start parent && child IPC test
// Testcase | start parent && child IPC test
// testing: is stderr and stdout piped to parent
const args = [process.argv[1], 'parent'];

View File

@ -23,7 +23,7 @@
const common = require('../common');
const assert = require('assert');
// if child process output to console and exit
// If child process output to console and exit
if (process.argv[2] === 'child') {
console.log('hello');
for (let i = 0; i < 200; i++) {

View File

@ -14,7 +14,7 @@ assert.throws(() => _validateStdio('foo'), expectedError);
// should throw if not a string or array
assert.throws(() => _validateStdio(600), expectedError);
// should populate stdio with undefined if len < 3
// Should populate stdio with undefined if len < 3
{
const stdio1 = [];
const result = _validateStdio(stdio1, false);
@ -24,7 +24,7 @@ assert.throws(() => _validateStdio(600), expectedError);
assert.strictEqual(result.hasOwnProperty('ipcFd'), true);
}
// should throw if stdio has ipc and sync is true
// Should throw if stdio has ipc and sync is true
const stdio2 = ['ipc', 'ipc', 'ipc'];
common.expectsError(() => _validateStdio(stdio2, true),
{ code: 'ERR_IPC_SYNC_FORK', type: Error }

View File

@ -6,7 +6,7 @@ const { exec } = require('child_process');
const node = process.execPath;
// should throw if -c and -e flags are both passed
// Should throw if -c and -e flags are both passed
['-c', '--check'].forEach(function(checkFlag) {
['-e', '--eval'].forEach(function(evalFlag) {
const args = [checkFlag, evalFlag, 'foo'];

View File

@ -6,7 +6,7 @@ const { spawnSync } = require('child_process');
const node = process.execPath;
// test both sets of arguments that check syntax
// Test both sets of arguments that check syntax
const syntaxArgs = [
['-c'],
['--check']

View File

@ -6,7 +6,7 @@ const { spawnSync } = require('child_process');
const node = process.execPath;
// test both sets of arguments that check syntax
// Test both sets of arguments that check syntax
const syntaxArgs = [
['-c'],
['--check']

View File

@ -26,7 +26,7 @@ const cluster = require('cluster');
const fork = cluster.fork;
if (cluster.isMaster) {
fork(); // it is intentionally called `fork` instead of
fork(); // It is intentionally called `fork` instead of
fork(); // `cluster.fork` to test that `this` is not used
cluster.disconnect(common.mustCall(() => {
assert.deepStrictEqual(Object.keys(cluster.workers), []);

View File

@ -52,7 +52,7 @@ if (cluster.isWorker) {
});
};
// test both servers created in the cluster
// Test both servers created in the cluster
const testCluster = (cb) => {
let done = 0;
const portsArray = Array.from(serverPorts);

View File

@ -38,7 +38,7 @@ if (cluster.isMaster && process.argv.length !== 3) {
const PIPE_NAME = common.PIPE;
const worker = cluster.fork({ PIPE_NAME });
// makes sure master is able to fork the worker
// Makes sure master is able to fork the worker
cluster.on('fork', common.mustCall());
// makes sure the worker is ready
@ -57,14 +57,14 @@ if (cluster.isMaster && process.argv.length !== 3) {
// Message from the child indicates it's ready and listening
cp.on('message', common.mustCall(function() {
const server = net.createServer().listen(PIPE_NAME, function() {
// message child process so that it can exit
// Message child process so that it can exit
cp.send('end');
// inform master about the unexpected situation
// Inform master about the unexpected situation
process.send('PIPE should have been in use.');
});
server.on('error', function(err) {
// message to child process tells it to exit
// Message to child process tells it to exit
cp.send('end');
// propagate error to parent
process.send(err);

View File

@ -64,7 +64,7 @@ if (cluster.isWorker) {
let alive = true;
master.on('exit', common.mustCall((code) => {
// make sure that the master died on purpose
// Make sure that the master died on purpose
assert.strictEqual(code, 0);
// check worker process status

View File

@ -67,7 +67,7 @@ if (cluster.isWorker) {
// start worker
const worker = cluster.fork();
// when the worker is up and running, kill it
// When the worker is up and running, kill it
worker.once('listening', common.mustCall(() => {
worker.process.kill(KILL_SIGNAL);
}));

View File

@ -50,7 +50,7 @@ if (cluster.isMaster) {
destroyed = true;
}, 1000);
}).once('exit', function() {
// worker should not exit while it has a connection
// Worker should not exit while it has a connection
assert(destroyed, 'worker exited before connection destroyed');
success = true;
});

View File

@ -24,7 +24,7 @@ if (cluster.isWorker) {
// Check worker events and properties
process.once('disconnect', function() {
// disconnect should occur after socket close
// Disconnect should occur after socket close
assert(serverClosed);
clearInterval(keepOpen);
});

View File

@ -145,7 +145,7 @@ console.dirxml(
// test console.trace()
console.trace('This is a %j %d', { formatted: 'trace' }, 10, 'foo');
// test console.time() and console.timeEnd() output
// Test console.time() and console.timeEnd() output
console.time('label');
console.timeEnd('label');

View File

@ -19,7 +19,7 @@ assert.ok(binding.crypto);
assert.strictEqual(binding[l][k][j], constants[j]);
});
}
if (l !== 'os') { // top level os constant isn't currently copied
if (l !== 'os') { // Top level os constant isn't currently copied
assert.strictEqual(binding[l][k], constants[k]);
}
});

View File

@ -199,7 +199,7 @@ for (const test of TEST_CASES) {
}
{
// trying to get tag before inputting all data:
// Trying to get tag before inputting all data:
const encrypt = crypto.createCipheriv(test.algo,
Buffer.from(test.key, 'hex'),
Buffer.from(test.iv, 'hex'),
@ -209,7 +209,7 @@ for (const test of TEST_CASES) {
}
{
// trying to create cipher with incorrect IV length
// Trying to create cipher with incorrect IV length
assert.throws(function() {
crypto.createCipheriv(
test.algo,

View File

@ -465,7 +465,7 @@ function testCipher1(key) {
const plaintext = 'Keep this a secret? No! Tell everyone about node.js!';
const cipher = crypto.createCipher('aes192', key);
// encrypt plaintext which is in utf8 format
// Encrypt plaintext which is in utf8 format
// to a ciphertext which will be in hex
let ciph = cipher.update(plaintext, 'utf8', 'hex');
// Only use binary or hex, not base64.
@ -488,7 +488,7 @@ function testCipher2(key) {
'jAfaFg**';
const cipher = crypto.createCipher('aes256', key);
// encrypt plaintext which is in utf8 format
// Encrypt plaintext which is in utf8 format
// to a ciphertext which will be in Base64
let ciph = cipher.update(plaintext, 'utf8', 'base64');
ciph += cipher.final('base64');

View File

@ -24,7 +24,7 @@ function testCipher1(key) {
const plaintext = 'Keep this a secret? No! Tell everyone about node.js!';
const cipher = crypto.createCipher('aes192', key);
// encrypt plaintext which is in utf8 format
// Encrypt plaintext which is in utf8 format
// to a ciphertext which will be in hex
let ciph = cipher.update(plaintext, 'utf8', 'hex');
// Only use binary or hex, not base64.
@ -61,7 +61,7 @@ function testCipher2(key) {
'jAfaFg**';
const cipher = crypto.createCipher('aes256', key);
// encrypt plaintext which is in utf8 format
// Encrypt plaintext which is in utf8 format
// to a ciphertext which will be in Base64
let ciph = cipher.update(plaintext, 'utf8', 'base64');
ciph += cipher.final('base64');

View File

@ -374,7 +374,7 @@ if (availableCurves.has('prime256v1') && availableHashes.has('sha256')) {
crypto.createSign('SHA256').sign(ecPrivateKey);
}
// invalid test: curve argument is undefined
// Invalid test: curve argument is undefined
common.expectsError(
() => crypto.createECDH(),
{

View File

@ -42,7 +42,7 @@ while (ucs2_control.length <= EXTERN_APEX) {
}
// check resultant buffer and output string
// Check resultant buffer and output string
const b = Buffer.from(ucs2_control + ucs2_control, 'ucs2');
//

View File

@ -81,7 +81,7 @@ assert.deepStrictEqual(
`${cryptoType} with ${digest} digest failed to evaluate to expected hash`
);
// stream interface should produce the same result.
// Stream interface should produce the same result.
assert.deepStrictEqual(a5, a3);
assert.deepStrictEqual(a6, a3);
assert.notStrictEqual(a7, undefined);

View File

@ -33,7 +33,7 @@ const { kMaxLength } = require('buffer');
const kMaxUint32 = Math.pow(2, 32) - 1;
const kMaxPossibleLength = Math.min(kMaxLength, kMaxUint32);
// bump, we register a lot of exit listeners
// Bump, we register a lot of exit listeners
process.setMaxListeners(256);
common.expectWarning('DeprecationWarning',

View File

@ -40,7 +40,7 @@ const server = http.createServer(function(req, res) {
dom.on('error', function(er) {
serverCaught++;
console.log('horray! got a server error', er);
// try to send a 500. If that fails, oh well.
// Try to send a 500. If that fails, oh well.
res.writeHead(500, { 'content-type': 'text/plain' });
res.end(er.stack || er.message || 'Unknown error');
});
@ -50,7 +50,7 @@ const server = http.createServer(function(req, res) {
// if you request 'baz', then it'll throw a JSON circular ref error.
const data = JSON.stringify(objects[req.url.replace(/[^a-z]/g, '')]);
// this line will throw if you pick an unknown key
// This line will throw if you pick an unknown key
assert.notStrictEqual(data, undefined);
res.writeHead(200);

View File

@ -48,7 +48,7 @@ const fileData = fs.readFileSync(filename);
assert.strictEqual(Buffer.byteLength(data), fileData.length);
// test that appends data to a non empty file
// Test that appends data to a non empty file
const filename2 = join(tmpdir.path, 'append-sync2.txt');
fs.writeFileSync(filename2, currentFileData);
@ -59,7 +59,7 @@ const fileData2 = fs.readFileSync(filename2);
assert.strictEqual(Buffer.byteLength(data) + currentFileData.length,
fileData2.length);
// test that appendFileSync accepts buffers
// Test that appendFileSync accepts buffers
const filename3 = join(tmpdir.path, 'append-sync3.txt');
fs.writeFileSync(filename3, currentFileData);
@ -87,7 +87,7 @@ const fileData4 = fs.readFileSync(filename4);
assert.strictEqual(Buffer.byteLength(String(num)) + currentFileData.length,
fileData4.length);
// test that appendFile accepts file descriptors
// Test that appendFile accepts file descriptors
const filename5 = join(tmpdir.path, 'append-sync5.txt');
fs.writeFileSync(filename5, currentFileData);

View File

@ -30,7 +30,7 @@ const assert = require('assert');
const tmpdir = require('../common/tmpdir');
// make a path that will be at least 260 chars long.
// Make a path that will be at least 260 chars long.
const fileNameLen = Math.max(260 - tmpdir.path.length - 1, 1);
const fileName = path.join(tmpdir.path, 'x'.repeat(fileNameLen));
const fullPath = path.resolve(fileName);

View File

@ -33,7 +33,7 @@ function nextdir() {
return `test${++dirc}`;
}
// mkdir creates directory using assigned path
// fs.mkdir creates directory using assigned path
{
const pathname = path.join(tmpdir.path, nextdir());
@ -43,7 +43,7 @@ function nextdir() {
}));
}
// mkdir creates directory with assigned mode value
// fs.mkdir creates directory with assigned mode value
{
const pathname = path.join(tmpdir.path, nextdir());

View File

@ -254,7 +254,7 @@ async function getHandle(dest) {
await unlink(newLink);
}
// testing readdir lists both files and directories
// Testing readdir lists both files and directories
{
const newDir = path.resolve(tmpDir, 'dir');
const newFile = path.resolve(tmpDir, 'foo.js');
@ -326,8 +326,8 @@ async function getHandle(dest) {
assert(stats.isDirectory());
}
// mkdirp require recursive option to be a boolean.
// Anything else generates an error.
// fs.mkdirp requires the recursive option to be of type boolean.
// Everything else generates an error.
{
const dir = path.join(tmpDir, nextdir(), nextdir());
['', 1, {}, [], null, Symbol('test'), () => {}].forEach((recursive) => {

View File

@ -1,7 +1,7 @@
'use strict';
const common = require('../common');
// simulate `cat readfile.js | node readfile.js`
// Simulate `cat readfile.js | node readfile.js`
if (common.isWindows || common.isAIX)
common.skip(`No /dev/stdin on ${process.platform}.`);

View File

@ -22,7 +22,7 @@
'use strict';
const common = require('../common');
// simulate `cat readfile.js | node readfile.js`
// Simulate `cat readfile.js | node readfile.js`
if (common.isWindows || common.isAIX)
common.skip(`No /dev/stdin on ${process.platform}.`);

View File

@ -29,7 +29,7 @@ const fs = require('fs');
const dataExpected = fs.readFileSync(__filename, 'utf8');
// sometimes stat returns size=0, but it's a lie.
// Sometimes stat returns size=0, but it's a lie.
fs._fstat = fs.fstat;
fs._fstatSync = fs.fstatSync;

View File

@ -1,7 +1,7 @@
'use strict';
const common = require('../common');
// simulate `cat readfile.js | node readfile.js`
// Simulate `cat readfile.js | node readfile.js`
if (common.isWindows || common.isAIX)
common.skip(`No /dev/stdin on ${process.platform}.`);

View File

@ -52,7 +52,7 @@ const watcher =
assert(prev.ino <= 0n);
// Stop watching the file
fs.unwatchFile(enoentFile);
watcher.stop(); // stopping a stopped watcher should be a noop
watcher.stop(); // Stopping a stopped watcher should be a noop
}
}, 2));
@ -60,4 +60,4 @@ const watcher =
// not trigger a 'stop' event.
watcher.on('stop', common.mustCall(function onStop() {}));
watcher.start(); // starting a started watcher should be a noop
watcher.start(); // Starting a started watcher should be a noop

Some files were not shown because too many files have changed in this diff Show More