Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
- Remove redundant 'use strict' directives as modules are automatically in strict mode
- Refactor assignment-in-expression patterns to improve code clarity and readability
- Replace comma operators with individual statements for clearer, more readable code
- Split comma-separated variable declarations into individual statements for consistency
- Replace Object.prototype.hasOwnProperty() with safer Object.hasOwn() method
- Enforce strict equality checks (=== and !==) instead of loose equality (== and !=)
- Replace global isNaN with Number.isNaN for safer type checking
Expand Down
3 changes: 3 additions & 0 deletions biome.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
"noGlobalIsFinite": "error",
"noPrototypeBuiltins": "error",
"noVar": "error"
},
"style": {
"useSingleVarDeclarator": "error"
}
}
},
Expand Down
4 changes: 2 additions & 2 deletions examples/tutorials/callback_api/rpc_server.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ amqp.connect((err, connection) => {
function fib(n) {
// Do it the ridiculous, but not most ridiculous, way. For better,
// see http://nayuki.eigenstate.org/page/fast-fibonacci-algorithms
let a = 0,
b = 1;
let a = 0;
let b = 1;
for (let i = 0; i < n; i++) {
const c = a + b;
a = b;
Expand Down
4 changes: 2 additions & 2 deletions examples/tutorials/rpc_server.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ const queue = 'rpc_queue';
function fib(n) {
// Do it the ridiculous, but not most ridiculous, way. For better,
// see http://nayuki.eigenstate.org/page/fast-fibonacci-algorithms
let a = 0,
b = 1;
let a = 0;
let b = 1;
for (let i = 0; i < n; i++) {
const c = a + b;
a = b;
Expand Down
4 changes: 2 additions & 2 deletions lib/bitset.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@ function trailingZeros(i) {
// since bit ops are not necessarily the quick way to do things in
// JS.
if (i === 0) return 32;
let y,
n = 31;
let y;
let n = 31;
y = i << 16;
if (y !== 0) {
n = n - 16;
Expand Down
4 changes: 2 additions & 2 deletions lib/channel.js
Original file line number Diff line number Diff line change
Expand Up @@ -370,8 +370,8 @@ function acceptDeliveryOrReturn(f) {
// Move to the state of waiting for message frames (headers, then
// one or more content frames)
function acceptMessage(continuation) {
let totalSize = 0,
remaining = 0;
let totalSize = 0;
let remaining = 0;
let buffers = null;

const message = {
Expand Down
14 changes: 8 additions & 6 deletions lib/codec.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ function encodeArray(buffer, val, offset) {

function encodeFieldValue(buffer, value, offset) {
const start = offset;
let type = typeof value,
val = value;
let type = typeof value;
let val = value;
// A trapdoor for specifying a type, e.g., timestamp
if (value && type === 'object' && Object.hasOwn(value, '!')) {
val = value.value;
Expand Down Expand Up @@ -206,10 +206,12 @@ function encodeFieldValue(buffer, value, offset) {
// Assume we're given a slice of the buffer that contains just the
// fields.
function decodeFields(slice) {
let fields = {},
offset = 0,
size = slice.length;
let len, key, val;
const fields = {};
let offset = 0;
const size = slice.length;
let len;
let key;
let val;

function decodeFieldValue() {
const tag = String.fromCharCode(slice[offset]);
Expand Down
10 changes: 6 additions & 4 deletions lib/connect.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ function openFrames(vhost, query, credentials, extraClientProperties) {

// Decide on credentials based on what we're supplied.
function credentialsFromUrl(parts) {
let user = 'guest',
passwd = 'guest';
let user = 'guest';
let passwd = 'guest';
if (parts.username !== '' || parts.password !== '') {
user = parts.username ? unescape(parts.username) : '';
passwd = parts.password ? unescape(parts.password) : '';
Expand All @@ -93,14 +93,16 @@ function connect(url, socketOptions, openCallback) {

const extraClientProperties = sockopts.clientProperties || {};

let protocol, fields;
let protocol;
let fields;
if (typeof url === 'object') {
protocol = `${url.protocol || 'amqp'}:`;
sockopts.host = url.hostname;
sockopts.servername = sockopts.servername || url.hostname;
sockopts.port = url.port || (protocol === 'amqp:' ? 5672 : 5671);

let user, pass;
let user;
let pass;
// Only default if both are missing, to have the same behaviour as
// the stringly URL.
if (url.username === undefined && url.password === undefined) {
Expand Down
10 changes: 5 additions & 5 deletions lib/frame.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ module.exports.PROTOCOL_HEADER = `AMQP${String.fromCharCode(0, 0, 9, 1)}`;
*/

// framing constants
const FRAME_METHOD = constants.FRAME_METHOD,
FRAME_HEARTBEAT = constants.FRAME_HEARTBEAT,
FRAME_HEADER = constants.FRAME_HEADER,
FRAME_BODY = constants.FRAME_BODY,
FRAME_END = constants.FRAME_END;
const FRAME_METHOD = constants.FRAME_METHOD;
const FRAME_HEARTBEAT = constants.FRAME_HEARTBEAT;
const FRAME_HEADER = constants.FRAME_HEADER;
const FRAME_BODY = constants.FRAME_BODY;
const FRAME_END = constants.FRAME_END;

// expected byte sizes for frame parts
const TYPE_BYTES = 1;
Expand Down
6 changes: 3 additions & 3 deletions test/channel.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ const promisify = require('node:util').promisify;
const Channel = require('../lib/channel').Channel;
const Connection = require('../lib/connection').Connection;
const util = require('./util');
const succeed = util.succeed,
fail = util.fail,
latch = util.latch;
const succeed = util.succeed;
const fail = util.fail;
const latch = util.latch;
const completes = util.completes;
const defs = require('../lib/defs');
const conn_handshake = require('./connection').connection_handshake;
Expand Down
16 changes: 8 additions & 8 deletions test/channel_api.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
const assert = require('node:assert');
const api = require('../channel_api');
const util = require('./util');
const succeed = util.succeed,
fail = util.fail;
const succeed = util.succeed;
const fail = util.fail;
const schedule = util.schedule;
const randomString = util.randomString;
const promisify = require('node:util').promisify;
Expand Down Expand Up @@ -273,11 +273,11 @@ suite('binding, consuming', () => {
// To some extent this is now just testing semantics of the server,
// but we can at least try out a few settings, and consume.
chtest('consume via exchange-exchange binding', (ch) => {
const ex1 = 'test.ex-ex-binding1',
ex2 = 'test.ex-ex-binding2';
const ex1 = 'test.ex-ex-binding1';
const ex2 = 'test.ex-ex-binding2';
const q = 'test.ex-ex-binding-q';
const rk = 'test.routing.key',
msg = randomString();
const rk = 'test.routing.key';
const msg = randomString();
return Promise.all([
ch.assertExchange(ex1, 'direct', EX_OPTS),
ch.assertExchange(ex2, 'fanout', {durable: false, internal: true}),
Expand Down Expand Up @@ -396,8 +396,8 @@ suite('binding, consuming', () => {
// ack, by default, removes a single message from the queue
chtest('ack', (ch) => {
const q = 'test.ack';
const msg1 = randomString(),
msg2 = randomString();
const msg1 = randomString();
const msg2 = randomString();

return Promise.all([ch.assertQueue(q, QUEUE_OPTS), ch.purgeQueue(q)])
.then(() => {
Expand Down
6 changes: 3 additions & 3 deletions test/codec.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,9 @@ function bufferToArray(b) {

suite('Implicit encodings', () => {
testCases.forEach((tc) => {
const name = tc[0],
val = tc[1],
expect = tc[2];
const name = tc[0];
const val = tc[1];
const expect = tc[2];
test(name, () => {
const buffer = Buffer.alloc(1000);
const size = codec.encodeTable(buffer, val, 0);
Expand Down
18 changes: 9 additions & 9 deletions test/connect.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ const defs = require('../lib/defs');
const assert = require('node:assert');
const util = require('./util');
const net = require('node:net');
const fail = util.fail,
succeed = util.succeed,
latch = util.latch,
kCallback = util.kCallback,
succeedIfAttributeEquals = util.succeedIfAttributeEquals;
const fail = util.fail;
const succeed = util.succeed;
const latch = util.latch;
const kCallback = util.kCallback;
const succeedIfAttributeEquals = util.succeedIfAttributeEquals;
const format = require('node:util').format;

const URL = process.env.URL || 'amqp://localhost';
Expand Down Expand Up @@ -107,8 +107,8 @@ suite('Connect API', () => {
test('using plain credentials', (done) => {
const url = require('node:url');
const parts = url.parse(URL, true);
let u = 'guest',
p = 'guest';
let u = 'guest';
let p = 'guest';
if (parts.auth) {
const auth = parts.auth.split(':');
u = auth[0];
Expand All @@ -120,8 +120,8 @@ suite('Connect API', () => {
test('using amqplain credentials', (done) => {
const url = require('node:url');
const parts = url.parse(URL, true);
let u = 'guest',
p = 'guest';
let u = 'guest';
let p = 'guest';
if (parts.auth) {
const auth = parts.auth.split(':');
u = auth[0];
Expand Down
6 changes: 3 additions & 3 deletions test/connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ const Connection = require('../lib/connection').Connection;
const HEARTBEAT = require('../lib/frame').HEARTBEAT;
const HB_BUF = require('../lib/frame').HEARTBEAT_BUF;
const util = require('./util');
const succeed = util.succeed,
fail = util.fail,
latch = util.latch;
const succeed = util.succeed;
const fail = util.fail;
const latch = util.latch;
const completes = util.completes;
const kCallback = util.kCallback;

Expand Down
4 changes: 2 additions & 2 deletions test/frame.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@ suite('Parsing', () => {
const bufs = [];
const input = inputs();
const frames = new Frames(input);
let i = 0,
ex;
let i = 0;
let ex;
frames.accept = (f) => {
// A minor hack to make sure we get the assertion exception;
// otherwise, it's just a test that we reached the line
Expand Down
4 changes: 2 additions & 2 deletions test/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,8 @@ function versionGreaterThan(actual, spec) {
const version = actual.split('.').map(int);
const desired = spec.split('.').map(int);
for (let i = 0; i < desired.length; i++) {
const a = version[i],
b = desired[i];
const a = version[i];
const b = desired[i];
if (a !== b) return a > b;
}
return false;
Expand Down