Skip to content

Commit

Permalink
chore: use ES6 for...of instead of forEach (#228)
Browse files Browse the repository at this point in the history
  • Loading branch information
erfanium authored Aug 13, 2021
1 parent 88dd176 commit 3f32126
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 12 deletions.
6 changes: 3 additions & 3 deletions src/cluster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,12 +124,12 @@ export class Cluster {
}

close() {
this.#connections.forEach((connection) => {
for (const conn of this.#connections) {
try {
Deno.close(connection.rid);
Deno.close(conn.rid);
} catch (error) {
console.error(`Error closing connection: ${error}`);
}
});
}
}
}
4 changes: 2 additions & 2 deletions src/protocol/message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,10 @@ export function serializeMessage(message: Message): Uint8Array[] {
view.setInt32(0, message.flags ?? 0, true);

let pos = 4;
sections.forEach((section) => {
for (const section of sections) {
buffer.set(section, pos);
pos += section.byteLength;
});
}

const header = serializeHeader({
messageLength: 16 + buffer.byteLength,
Expand Down
4 changes: 2 additions & 2 deletions src/protocol/protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,13 @@ export class WireProtocol {

let documents: T[] = [];

message?.sections.forEach((section) => {
for (const section of message?.sections!) {
if ("document" in section) {
documents.push(section.document as T);
} else {
documents = documents.concat(section.documents as T[]);
}
});
}

return documents;
}
Expand Down
4 changes: 2 additions & 2 deletions src/utils/srv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,11 @@ export class Srv {
valid: {},
illegal: [],
};
optionsUri.split("&").forEach((option: string) => {
for (const option of optionsUri.split("&")) {
const [key, value] = option.split("=");
if (isAllowedOption(key) && !!value) options.valid[key] = value;
else options.illegal.push(option);
});
}

if (options.illegal.length !== 0) {
throw new SRVError(
Expand Down
6 changes: 3 additions & 3 deletions tests/cases/01_auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ interface PasswordValid {
digest: string;
}

const passwordValdis: PasswordValid[] = [
const passwordValids: PasswordValid[] = [
{
username: "user",
password: "pencil",
Expand All @@ -30,15 +30,15 @@ const passwordValdis: PasswordValid[] = [
];

export default function authTests() {
passwordValdis.forEach(({ username, password, digest }) => {
for (const { username, password, digest } of passwordValids) {
Deno.test({
name: `passwordDigest:${username}:${password}`,
fn() {
const digestRes: string = passwordDigest(username, password);
assertEquals(digestRes, digest);
},
});
});
}

Deno.test({
name: "clientFirstMessageBare",
Expand Down

0 comments on commit 3f32126

Please sign in to comment.