Socket
Socket
Sign inDemoInstall

amqplib-easy

Package Overview
Dependencies
Maintainers
2
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

amqplib-easy - npm Package Compare versions

Comparing version 3.2.0 to 3.2.1

55

index.js

@@ -39,2 +39,15 @@ 'use strict';

function createChannel() {
return connect().then(function (connection) {
return BPromise.resolve(connection.createChannel());
});
}
function createChannelDisposer() {
return createChannel()
.disposer(function (channel) {
return channel.close();
});
}
function consume(queueConfig, handler) {

@@ -61,6 +74,3 @@ var options = defaults({}, queueConfig || {}, {

return connect()
.then(function (conn) {
return conn.createChannel();
})
return createChannel()
.then(function (ch) {

@@ -129,7 +139,5 @@ ch.prefetch(options.prefetch);

function publish(queueConfig, key, json, messageOptions) {
return connect()
.then(function (conn) {
return conn.createChannel();
})
.tap(function (ch) {
return BPromise.using(
createChannelDisposer(),
function (ch) {
if (queueConfig.exchange === null || queueConfig.exchange === undefined) {

@@ -141,19 +149,17 @@ throw new Error('Client tries to publish to an exchange while exchange name is not undefined.');

queueConfig.queue ? ch.assertQueue(queueConfig.queue, queueConfig.queueOptions || {durable: true}) : BPromise.resolve()
]);
})
.then(function (ch) {
return ch.publish(queueConfig.exchange,
key,
toBuffer(json),
messageOptions || queueConfig.messageOptions || {persistent: true});
});
])
.then(function () {
return ch.publish(queueConfig.exchange,
key,
toBuffer(json),
messageOptions || queueConfig.messageOptions || {persistent: true});
});
}
);
}
function sendToQueue(queueConfig, json, messageOptions) {
return connect()
.then(function (conn) {
// optional future =improvement - maybe we should keep the channel open?
return conn.createChannel();
})
.then(function (ch) {
return BPromise.using(
createChannelDisposer(),
function (ch) {
return ch.assertQueue(queueConfig.queue, queueConfig.queueOptions || {durable: true})

@@ -167,3 +173,4 @@ .then(function () {

});
});
}
);
}

@@ -170,0 +177,0 @@

{
"name": "amqplib-easy",
"version": "3.2.0",
"version": "3.2.1",
"description": "Simplified API for interacting with AMQP",

@@ -5,0 +5,0 @@ "main": "index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc