Change let into const (#457)

This patch:
- changes `let` into `const` throughout codebase
- adds eslint check to prefer const over let
This commit is contained in:
Eric Bidelman
2017-08-21 16:39:04 -07:00
committed by Andrey Lushnikov
parent 5d6d3e0a81
commit 1f9b4fb4c8
37 changed files with 495 additions and 494 deletions

View File

@@ -32,7 +32,7 @@ class SimpleServer {
* @return {!SimpleServer}
*/
static async create(dirPath, port) {
let server = new SimpleServer(dirPath, port);
const server = new SimpleServer(dirPath, port);
await new Promise(x => server._server.once('listening', x));
return server;
}
@@ -43,7 +43,7 @@ class SimpleServer {
* @return {!SimpleServer}
*/
static async createHTTPS(dirPath, port) {
let server = new SimpleServer(dirPath, port, {
const server = new SimpleServer(dirPath, port, {
key: fs.readFileSync(path.join(__dirname, 'key.pem')),
cert: fs.readFileSync(path.join(__dirname, 'cert.pem')),
passphrase: 'aaaa',
@@ -93,7 +93,7 @@ class SimpleServer {
*/
async stop() {
this.reset();
for (let socket of this._sockets)
for (const socket of this._sockets)
socket.destroy();
this._sockets.clear();
await new Promise(x => this._server.close(x));
@@ -139,8 +139,8 @@ class SimpleServer {
reset() {
this._routes.clear();
let error = new Error('Static Server has been reset');
for (let subscriber of this._requestSubscribers.values())
const error = new Error('Static Server has been reset');
for (const subscriber of this._requestSubscribers.values())
subscriber[rejectSymbol].call(null, error);
this._requestSubscribers.clear();
}
@@ -152,11 +152,11 @@ class SimpleServer {
else
throw error;
});
let pathName = url.parse(request.url).path;
const pathName = url.parse(request.url).path;
// Notify request subscriber.
if (this._requestSubscribers.has(pathName))
this._requestSubscribers.get(pathName)[fulfillSymbol].call(null, request);
let handler = this._routes.get(pathName);
const handler = this._routes.get(pathName);
if (handler)
handler.call(null, request, response);
else