Skip to content

Commit 0aea4d1

Browse files
BridgeARBethGriggs
authored andcommitted
benchmark,lib: change var to const
Refs: #26679 PR-URL: #26915 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Refael Ackermann <refack@gmail.com> Signed-off-by: Beth Griggs <Bethany.Griggs@uk.ibm.com>
1 parent 0f615d4 commit 0aea4d1

Some content is hidden

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

44 files changed

+343
-346
lines changed

benchmark/fs/readfile-partitioned.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ function main(conf) {
2929
fs.writeFileSync(filename, data);
3030
data = null;
3131

32-
var zipData = Buffer.alloc(1024, 'a');
32+
const zipData = Buffer.alloc(1024, 'a');
3333

3434
var reads = 0;
3535
var zips = 0;

benchmark/fs/write-stream-throughput.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ function main({ dur, encodingType, size }) {
3838
var started = false;
3939
var ended = false;
4040

41-
var f = fs.createWriteStream(filename);
41+
const f = fs.createWriteStream(filename);
4242
f.on('drain', write);
4343
f.on('open', write);
4444
f.on('close', done);

benchmark/http/_chunky_http_client.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ function main({ len, n }) {
5454
const add = 11;
5555
var count = 0;
5656
const PIPE = process.env.PIPE_NAME;
57-
var socket = net.connect(PIPE, () => {
57+
const socket = net.connect(PIPE, () => {
5858
bench.start();
5959
WriteHTTPHeaders(socket, 1, len);
6060
socket.setEncoding('utf8');

benchmark/http/http_server_for_chunky_client.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,7 @@ process.env.PIPE_NAME = PIPE;
1010

1111
tmpdir.refresh();
1212

13-
var server;
14-
15-
server = http.createServer((req, res) => {
13+
const server = http.createServer((req, res) => {
1614
const headers = {
1715
'content-type': 'text/plain',
1816
'content-length': '2'

benchmark/http/set-header.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const c = 50;
1717
// setHeaderWH: setHeader(...), writeHead(status, ...)
1818
function main({ res }) {
1919
process.env.PORT = PORT;
20-
var server = require('../fixtures/simple-http-server.js')
20+
const server = require('../fixtures/simple-http-server.js')
2121
.listen(PORT)
2222
.on('listening', () => {
2323
const path = `/${type}/${len}/${chunks}/normal/${chunkedEnc}`;

benchmark/http/simple.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const bench = common.createBenchmark(main, {
1111
});
1212

1313
function main({ type, len, chunks, c, chunkedEnc, res }) {
14-
var server = require('../fixtures/simple-http-server.js')
14+
const server = require('../fixtures/simple-http-server.js')
1515
.listen(common.PORT)
1616
.on('listening', () => {
1717
const path = `/${type}/${len}/${chunks}/normal/${chunkedEnc}`;

benchmark/http/upgrade.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ const resData = 'HTTP/1.1 101 Web Socket Protocol Handshake\r\n' +
1919
'\r\n\r\n';
2020

2121
function main({ n }) {
22-
var server = require('../fixtures/simple-http-server.js')
22+
const server = require('../fixtures/simple-http-server.js')
2323
.listen(common.PORT)
2424
.on('listening', () => {
2525
bench.start();

benchmark/tls/throughput.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ const tls = require('tls');
1414

1515
function main({ dur, type, size }) {
1616
var encoding;
17-
var server;
1817
var chunk;
1918
switch (type) {
2019
case 'buf':
@@ -39,7 +38,7 @@ function main({ dur, type, size }) {
3938
ciphers: 'AES256-GCM-SHA384'
4039
};
4140

42-
server = tls.createServer(options, onConnection);
41+
const server = tls.createServer(options, onConnection);
4342
var conn;
4443
server.listen(common.PORT, () => {
4544
const opt = { port: common.PORT, rejectUnauthorized: false };

benchmark/tls/tls-connect.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ function makeConnection() {
4646
port: common.PORT,
4747
rejectUnauthorized: false
4848
};
49-
var conn = tls.connect(options, () => {
49+
const conn = tls.connect(options, () => {
5050
clientConn++;
5151
conn.on('error', (er) => {
5252
console.error('client error', er);

lib/_http_agent.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ function Agent(options) {
6161
this.maxFreeSockets = this.options.maxFreeSockets || 256;
6262

6363
this.on('free', (socket, options) => {
64-
var name = this.getName(options);
64+
const name = this.getName(options);
6565
debug('agent.on(free)', name);
6666

6767
if (socket.writable &&
@@ -153,13 +153,13 @@ Agent.prototype.addRequest = function addRequest(req, options, port/* legacy */,
153153
if (!options.servername)
154154
options.servername = calculateServerName(options, req);
155155

156-
var name = this.getName(options);
156+
const name = this.getName(options);
157157
if (!this.sockets[name]) {
158158
this.sockets[name] = [];
159159
}
160160

161-
var freeLen = this.freeSockets[name] ? this.freeSockets[name].length : 0;
162-
var sockLen = freeLen + this.sockets[name].length;
161+
const freeLen = this.freeSockets[name] ? this.freeSockets[name].length : 0;
162+
const sockLen = freeLen + this.sockets[name].length;
163163

164164
if (freeLen) {
165165
// We have a free socket, so use that.
@@ -200,7 +200,7 @@ Agent.prototype.createSocket = function createSocket(req, options, cb) {
200200
if (!options.servername)
201201
options.servername = calculateServerName(options, req);
202202

203-
var name = this.getName(options);
203+
const name = this.getName(options);
204204
options._agentKey = name;
205205

206206
debug('createConnection', name, options);
@@ -280,9 +280,9 @@ function installListeners(agent, s, options) {
280280
}
281281

282282
Agent.prototype.removeSocket = function removeSocket(s, options) {
283-
var name = this.getName(options);
283+
const name = this.getName(options);
284284
debug('removeSocket', name, 'writable:', s.writable);
285-
var sets = [this.sockets];
285+
const sets = [this.sockets];
286286

287287
// If the socket was destroyed, remove it from the free buffers too.
288288
if (!s.writable)
@@ -324,7 +324,7 @@ Agent.prototype.reuseSocket = function reuseSocket(socket, req) {
324324
};
325325

326326
Agent.prototype.destroy = function destroy() {
327-
var sets = [this.freeSockets, this.sockets];
327+
const sets = [this.freeSockets, this.sockets];
328328
for (var s = 0; s < sets.length; s++) {
329329
var set = sets[s];
330330
var keys = Object.keys(set);

0 commit comments

Comments
 (0)