Skip to content

Commit 605826f

Browse files
Await binding declaration
While at it, use `===` over `==` as in the original non-`async`/`await` version.
1 parent fc6bce3 commit 605826f

5 files changed

Lines changed: 12 additions & 12 deletions

File tree

javascript-nodejs/src/emit_log_topic.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ async function main() {
1515
durable: false
1616
});
1717
channel.publish(exchange, key, Buffer.from(msg));
18-
console.log(" [x] Sent %s:'%s'", key, msg);
18+
console.log(" [x] Sent %s: '%s'", key, msg);
1919

2020
setTimeout(function() {
2121
connection.close();

javascript-nodejs/src/receive_logs_direct.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const amqp = require('amqplib');
44

55
const args = process.argv.slice(2);
66

7-
if (args.length == 0) {
7+
if (args.length === 0) {
88
console.log("Usage: receive_logs_direct.js [info] [warning] [error]");
99
process.exit(1);
1010
}
@@ -24,9 +24,9 @@ async function main() {
2424
});
2525
console.log(' [*] Waiting for logs. To exit press CTRL+C');
2626

27-
args.forEach(function(severity) {
28-
channel.bindQueue(q.queue, exchange, severity);
29-
});
27+
for (const severity of args) {
28+
await channel.bindQueue(q.queue, exchange, severity);
29+
}
3030

3131
channel.consume(q.queue, function(msg) {
3232
console.log(" [x] %s: '%s'", msg.fields.routingKey, msg.content.toString());

javascript-nodejs/src/receive_logs_topic.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const amqp = require('amqplib');
44

55
const args = process.argv.slice(2);
66

7-
if (args.length == 0) {
7+
if (args.length === 0) {
88
console.log("Usage: receive_logs_topic.js <facility>.<severity>");
99
process.exit(1);
1010
}
@@ -24,9 +24,9 @@ async function main() {
2424
});
2525
console.log(' [*] Waiting for logs. To exit press CTRL+C');
2626

27-
args.forEach(function(key) {
28-
channel.bindQueue(q.queue, exchange, key);
29-
});
27+
for (const key of args) {
28+
await channel.bindQueue(q.queue, exchange, key);
29+
}
3030

3131
channel.consume(q.queue, function(msg) {
3232
console.log(" [x] %s:'%s'", msg.fields.routingKey, msg.content.toString());

javascript-nodejs/src/rpc_client.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const amqp = require('amqplib');
44

55
const args = process.argv.slice(2);
66

7-
if (args.length == 0) {
7+
if (args.length === 0) {
88
console.log("Usage: rpc_client.js num");
99
process.exit(1);
1010
}
@@ -20,7 +20,7 @@ async function main() {
2020

2121
// Consume from the Direct Reply-to pseudo-queue (noAck is mandatory)
2222
channel.consume('amq.rabbitmq.reply-to', function(msg) {
23-
if (msg.properties.correlationId == correlationId) {
23+
if (msg.properties.correlationId === correlationId) {
2424
console.log(' [.] Got %s', msg.content.toString());
2525
setTimeout(function() {
2626
connection.close();

javascript-nodejs/src/rpc_server.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ async function main() {
3131
}
3232

3333
function fibonacci(n) {
34-
if (n == 0 || n == 1)
34+
if (n === 0 || n === 1)
3535
return n;
3636
else
3737
return fibonacci(n - 1) + fibonacci(n - 2);

0 commit comments

Comments
 (0)