Skip to content

Commit c147f64

Browse files
BridgeARBethGriggs
authored andcommitted
benchmark,lib: change var to const
Refs: #26679 PR-URL: #26915 Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Tobias Nießen <[email protected]> Reviewed-By: Refael Ackermann <[email protected]>
1 parent 9b73336 commit c147f64

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

+341
-342
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
@@ -60,7 +60,7 @@ function Agent(options) {
6060
this.maxFreeSockets = this.options.maxFreeSockets || 256;
6161

6262
this.on('free', (socket, options) => {
63-
var name = this.getName(options);
63+
const name = this.getName(options);
6464
debug('agent.on(free)', name);
6565

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

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

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

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

202-
var name = this.getName(options);
202+
const name = this.getName(options);
203203
options._agentKey = name;
204204

205205
debug('createConnection', name, options);
@@ -279,9 +279,9 @@ function installListeners(agent, s, options) {
279279
}
280280

281281
Agent.prototype.removeSocket = function removeSocket(s, options) {
282-
var name = this.getName(options);
282+
const name = this.getName(options);
283283
debug('removeSocket', name, 'writable:', s.writable);
284-
var sets = [this.sockets];
284+
const sets = [this.sockets];
285285

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

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

0 commit comments

Comments
 (0)