Jelajahi Sumber

[CodeFactor] Apply fixes

codefactor-io 2 tahun lalu
induk
melakukan
b2fcaf111d
4 mengubah file dengan 8 tambahan dan 8 penghapusan
  1. 1 1
      lib/dataconnection.ts
  2. 1 1
      lib/logger.ts
  3. 1 1
      lib/mediaconnection.ts
  4. 5 5
      lib/peer.ts

+ 1 - 1
lib/dataconnection.ts

@@ -360,7 +360,7 @@ export class DataConnection
 		const blobs = util.chunk(blob);
 		logger.log(`DC#${this.connectionId} Try to send ${blobs.length} chunks...`);
 
-		for (let blob of blobs) {
+		for (const blob of blobs) {
 			this.send(blob, true);
 		}
 	}

+ 1 - 1
lib/logger.ts

@@ -62,7 +62,7 @@ class Logger {
 	private _print(logLevel: LogLevel, ...rest: any[]): void {
 		const copy = [LOG_PREFIX, ...rest];
 
-		for (let i in copy) {
+		for (const i in copy) {
 			if (copy[i] instanceof Error) {
 				copy[i] = "(" + copy[i].name + ") " + copy[i].message;
 			}

+ 1 - 1
lib/mediaconnection.ts

@@ -118,7 +118,7 @@ export class MediaConnection extends BaseConnection<MediaConnectionEvents> {
 		// Retrieve lost messages stored because PeerConnection not set up.
 		const messages = this.provider._getMessages(this.connectionId);
 
-		for (let message of messages) {
+		for (const message of messages) {
 			this.handleMessage(message);
 		}
 

+ 5 - 5
lib/peer.ts

@@ -160,7 +160,7 @@ export class Peer extends EventEmitter<PeerEvents> {
 	get connections(): Object {
 		const plainConnections = Object.create(null);
 
-		for (let [k, v] of this._connections) {
+		for (const [k, v] of this._connections) {
 			plainConnections[k] = v;
 		}
 
@@ -409,7 +409,7 @@ export class Peer extends EventEmitter<PeerEvents> {
 
 				// Find messages.
 				const messages = this._getMessages(connectionId);
-				for (let message of messages) {
+				for (const message of messages) {
 					connection.handleMessage(message);
 				}
 
@@ -567,7 +567,7 @@ export class Peer extends EventEmitter<PeerEvents> {
 			return null;
 		}
 
-		for (let connection of connections) {
+		for (const connection of connections) {
 			if (connection.connectionId === connectionId) {
 				return connection;
 			}
@@ -633,7 +633,7 @@ export class Peer extends EventEmitter<PeerEvents> {
 
 	/** Disconnects every connection on this peer. */
 	private _cleanup(): void {
-		for (let peerId of this._connections.keys()) {
+		for (const peerId of this._connections.keys()) {
 			this._cleanupPeer(peerId);
 			this._connections.delete(peerId);
 		}
@@ -647,7 +647,7 @@ export class Peer extends EventEmitter<PeerEvents> {
 
 		if (!connections) return;
 
-		for (let connection of connections) {
+		for (const connection of connections) {
 			connection.close();
 		}
 	}