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
9 changes: 9 additions & 0 deletions .claude/commands/lint-disable.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Please follow the following process when I ask you to disable a lint rule using /lint-disable $rule

1. Create and change to a new branch. Ask for the branch name.
2. If the rule is off by default, delete it (See https://biomejs.dev/linter/javascript/rules/ for rule details)
3. If the rule is on by default, configure it to off in biome.json
4. Update the project changelog
5. Add the changes
6. Commit the changes
7. Push the changes
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Please follow the following process when I ask you to enfore a new lint rule using /lint-enforce $rule
Please follow the following process when I ask you to enable a lint rule using /lint-enable $rule

1. Create and change to a new branch. Ask for the branch name.
2. Configure the rule to error in biome.json
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
- Replace global isNaN with Number.isNaN for safer type checking
- Ensure no variable redeclarations exist to prevent shadowing issues
- Replace global isFinite with Number.isFinite for safer numeric validation
- Enable useArrowFunction lint rule to prefer arrow functions for cleaner syntax

## v0.10.9
- Add support for IPv6 urls
Expand Down
2 changes: 1 addition & 1 deletion biome.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"complexity": {
"noCommaOperator": "off",
"noUselessCatch": "off",
"useArrowFunction": "off",
"useArrowFunction": "error",
"useOptionalChain": "off",
"noArguments": "off",
"useLiteralKeys": "off"
Expand Down
2 changes: 1 addition & 1 deletion callback_api.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ function connect(url, options, cb) {
if (typeof url === 'function') (cb = url), (url = false), (options = false);
else if (typeof options === 'function') (cb = options), (options = false);

raw_connect(url, options, function (err, c) {
raw_connect(url, options, (err, c) => {
if (err === null) cb(null, new CallbackModel(c));
else cb(err);
});
Expand Down
6 changes: 1 addition & 5 deletions channel_api.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,7 @@ const ChannelModel = require('./lib/channel_model').ChannelModel;
const promisify = require('node:util').promisify;

function connect(url, connOptions) {
return promisify(function (cb) {
return raw_connect(url, connOptions, cb);
})().then(function (conn) {
return new ChannelModel(conn);
});
return promisify((cb) => raw_connect(url, connOptions, cb))().then((conn) => new ChannelModel(conn));
}

module.exports.connect = connect;
Expand Down
2 changes: 1 addition & 1 deletion examples/tutorials/callback_api/receive_logs_direct.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ amqp.connect((err, connection) => {
else console.warn(' [x] Consumer cancelled');
},
{noAck: true},
function (err) {
(err) => {
if (err) return bail(err, connection);
console.log(' [*] Waiting for logs. To exit press CTRL+C.');
subscribeAll(channel, queue, severities, (err) => {
Expand Down
2 changes: 1 addition & 1 deletion examples/tutorials/callback_api/receive_logs_topic.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ amqp.connect((err, connection) => {
else console.warn(' [x] Consumer cancelled');
},
{noAck: true},
function (err) {
(err) => {
if (err) return bail(err, connection);
console.log(' [*] Waiting for logs. To exit press CTRL+C.');
subscribeAll(channel, queue, severities, (err) => {
Expand Down
2 changes: 1 addition & 1 deletion examples/tutorials/callback_api/rpc_server.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ amqp.connect((err, connection) => {
channel.ack(message);
},
{noAck: false},
function (err) {
(err) => {
if (err) return bail(err, conn);
console.log(' [x] Awaiting RPC requests. To exit press CTRL+C.');
},
Expand Down
220 changes: 97 additions & 123 deletions lib/api_args.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const EMPTY_OPTIONS = Object.freeze({});

const Args = {};

Args.assertQueue = function (queue, options) {
Args.assertQueue = (queue, options) => {
queue = queue || '';
options = options || EMPTY_OPTIONS;

Expand All @@ -66,19 +66,17 @@ Args.assertQueue = function (queue, options) {
};
};

Args.checkQueue = function (queue) {
return {
queue: queue,
passive: true, // switch to "completely different" mode
nowait: false,
durable: true,
autoDelete: false,
exclusive: false, // ignored
ticket: 0,
};
};

Args.deleteQueue = function (queue, options) {
Args.checkQueue = (queue) => ({
queue: queue,
passive: true, // switch to "completely different" mode
nowait: false,
durable: true,
autoDelete: false,
exclusive: false, // ignored
ticket: 0,
});

Args.deleteQueue = (queue, options) => {
options = options || EMPTY_OPTIONS;
return {
queue: queue,
Expand All @@ -89,37 +87,31 @@ Args.deleteQueue = function (queue, options) {
};
};

Args.purgeQueue = function (queue) {
return {
queue: queue,
ticket: 0,
nowait: false,
};
};

Args.bindQueue = function (queue, source, pattern, argt) {
return {
queue: queue,
exchange: source,
routingKey: pattern,
arguments: argt,
ticket: 0,
nowait: false,
};
};

Args.unbindQueue = function (queue, source, pattern, argt) {
return {
queue: queue,
exchange: source,
routingKey: pattern,
arguments: argt,
ticket: 0,
nowait: false,
};
};

Args.assertExchange = function (exchange, type, options) {
Args.purgeQueue = (queue) => ({
queue: queue,
ticket: 0,
nowait: false,
});

Args.bindQueue = (queue, source, pattern, argt) => ({
queue: queue,
exchange: source,
routingKey: pattern,
arguments: argt,
ticket: 0,
nowait: false,
});

Args.unbindQueue = (queue, source, pattern, argt) => ({
queue: queue,
exchange: source,
routingKey: pattern,
arguments: argt,
ticket: 0,
nowait: false,
});

Args.assertExchange = (exchange, type, options) => {
options = options || EMPTY_OPTIONS;
const argt = Object.create(options.arguments || null);
setIfDefined(argt, 'alternate-exchange', options.alternateExchange);
Expand All @@ -136,21 +128,19 @@ Args.assertExchange = function (exchange, type, options) {
};
};

Args.checkExchange = function (exchange) {
return {
exchange: exchange,
passive: true, // switch to 'may as well be another method' mode
nowait: false,
// ff are ignored
durable: true,
internal: false,
type: '',
autoDelete: false,
ticket: 0,
};
};

Args.deleteExchange = function (exchange, options) {
Args.checkExchange = (exchange) => ({
exchange: exchange,
passive: true, // switch to 'may as well be another method' mode
nowait: false,
// ff are ignored
durable: true,
internal: false,
type: '',
autoDelete: false,
ticket: 0,
});

Args.deleteExchange = (exchange, options) => {
options = options || EMPTY_OPTIONS;
return {
exchange: exchange,
Expand All @@ -160,34 +150,30 @@ Args.deleteExchange = function (exchange, options) {
};
};

Args.bindExchange = function (dest, source, pattern, argt) {
return {
source: source,
destination: dest,
routingKey: pattern,
arguments: argt,
ticket: 0,
nowait: false,
};
};

Args.unbindExchange = function (dest, source, pattern, argt) {
return {
source: source,
destination: dest,
routingKey: pattern,
arguments: argt,
ticket: 0,
nowait: false,
};
};
Args.bindExchange = (dest, source, pattern, argt) => ({
source: source,
destination: dest,
routingKey: pattern,
arguments: argt,
ticket: 0,
nowait: false,
});

Args.unbindExchange = (dest, source, pattern, argt) => ({
source: source,
destination: dest,
routingKey: pattern,
arguments: argt,
ticket: 0,
nowait: false,
});

// It's convenient to construct the properties and the method fields
// at the same time, since in the APIs, values for both can appear in
// `options`. Since the property or mthod field names don't overlap, I
// just return one big object that can be used for both purposes, and
// the encoder will pick out what it wants.
Args.publish = function (exchange, routingKey, options) {
Args.publish = (exchange, routingKey, options) => {
options = options || EMPTY_OPTIONS;

// The CC and BCC fields expect an array of "longstr", which would
Expand Down Expand Up @@ -246,7 +232,7 @@ Args.publish = function (exchange, routingKey, options) {
};
};

Args.consume = function (queue, options) {
Args.consume = (queue, options) => {
options = options || EMPTY_OPTIONS;
const argt = Object.create(options.arguments || null);
setIfDefined(argt, 'x-priority', options.priority);
Expand All @@ -262,14 +248,12 @@ Args.consume = function (queue, options) {
};
};

Args.cancel = function (consumerTag) {
return {
consumerTag: consumerTag,
nowait: false,
};
};
Args.cancel = (consumerTag) => ({
consumerTag: consumerTag,
nowait: false,
});

Args.get = function (queue, options) {
Args.get = (queue, options) => {
options = options || EMPTY_OPTIONS;
return {
ticket: 0,
Expand All @@ -278,38 +262,28 @@ Args.get = function (queue, options) {
};
};

Args.ack = function (tag, allUpTo) {
return {
deliveryTag: tag,
multiple: !!allUpTo,
};
};

Args.nack = function (tag, allUpTo, requeue) {
return {
deliveryTag: tag,
multiple: !!allUpTo,
requeue: requeue === undefined ? true : requeue,
};
};

Args.reject = function (tag, requeue) {
return {
deliveryTag: tag,
requeue: requeue === undefined ? true : requeue,
};
};

Args.prefetch = function (count, global) {
return {
prefetchCount: count || 0,
prefetchSize: 0,
global: !!global,
};
};

Args.recover = function () {
return {requeue: true};
};
Args.ack = (tag, allUpTo) => ({
deliveryTag: tag,
multiple: !!allUpTo,
});

Args.nack = (tag, allUpTo, requeue) => ({
deliveryTag: tag,
multiple: !!allUpTo,
requeue: requeue === undefined ? true : requeue,
});

Args.reject = (tag, requeue) => ({
deliveryTag: tag,
requeue: requeue === undefined ? true : requeue,
});

Args.prefetch = (count, global) => ({
prefetchCount: count || 0,
prefetchSize: 0,
global: !!global,
});

Args.recover = () => ({requeue: true});

module.exports = Object.freeze(Args);
Loading