mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
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:
committed by
Andrey Lushnikov
parent
5d6d3e0a81
commit
1f9b4fb4c8
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user