test: replace callback with arrow functions
PR-URL: https://github.com/nodejs/node/pull/24434 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
This commit is contained in:
parent
ce890a0d90
commit
e2140697aa
@ -13,16 +13,16 @@ const options = {
|
|||||||
|
|
||||||
const connections = {};
|
const connections = {};
|
||||||
|
|
||||||
const server = https.createServer(options, function(req, res) {
|
const server = https.createServer(options, (req, res) => {
|
||||||
const interval = setInterval(function() {
|
const interval = setInterval(() => {
|
||||||
res.write('data');
|
res.write('data');
|
||||||
}, 1000);
|
}, 1000);
|
||||||
interval.unref();
|
interval.unref();
|
||||||
});
|
});
|
||||||
|
|
||||||
server.on('connection', function(connection) {
|
server.on('connection', (connection) => {
|
||||||
const key = `${connection.remoteAddress}:${connection.remotePort}`;
|
const key = `${connection.remoteAddress}:${connection.remotePort}`;
|
||||||
connection.on('close', function() {
|
connection.on('close', () => {
|
||||||
delete connections[key];
|
delete connections[key];
|
||||||
});
|
});
|
||||||
connections[key] = connection;
|
connections[key] = connection;
|
||||||
@ -37,16 +37,16 @@ function shutdown() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
server.listen(0, function() {
|
server.listen(0, () => {
|
||||||
const requestOptions = {
|
const requestOptions = {
|
||||||
hostname: '127.0.0.1',
|
hostname: '127.0.0.1',
|
||||||
port: this.address().port,
|
port: server.address().port,
|
||||||
path: '/',
|
path: '/',
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
rejectUnauthorized: false
|
rejectUnauthorized: false
|
||||||
};
|
};
|
||||||
|
|
||||||
const req = https.request(requestOptions, function(res) {
|
const req = https.request(requestOptions, (res) => {
|
||||||
res.on('data', () => {});
|
res.on('data', () => {});
|
||||||
setImmediate(shutdown);
|
setImmediate(shutdown);
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user