Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

hare

Package Overview
Dependencies
Maintainers
1
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hare - npm Package Compare versions

Comparing version 0.0.15 to 0.2.0

20

lib/_getConnection.js

@@ -37,24 +37,4 @@ "use strict";

},
close: function () {
var ret = new comb.Promise();
if (this._defaultExchange) {
var connection = this.__connection, exchange = this._defaultExchange;
exchange.on("close", function (err) {
if (err) {
ret.errback(new Error("Unexpected Error closing connection"));
} else {
connection.destroy();
ret.callback();
}
});
exchange.on("error", ret.errback);
exchange.close();
} else {
ret.callback();
}
return ret;
}
}
}).as(module);

24

lib/index.js

@@ -22,6 +22,5 @@ "use strict";

var connect = (function connectWrapper() {
var connectionPromise, connection, isConnected = false;
function connect(url, opts) {
var connectionPromise = new Promise(), connection, isConnected = false;
function ready() {

@@ -31,2 +30,3 @@ isConnected = true;

connection.removeListener("error", connectionError);
//set up error logging
connection.on("error", errorHandler);

@@ -48,10 +48,14 @@ connectionPromise.callback(connection);

connection = amqp.createConnection(url, opts);
connection.once('ready', ready);
connection.once('error', connectionError);
connection.once("close", checkConnected);
return connectionPromise;
}
return function connect(url, opts) {
if (!connectionPromise) {
connectionPromise = new Promise();
connection = amqp.createConnection(url, opts);
connection.once('ready', ready);
connection.once('error', connectionError);
connection.once("close", checkConnected);
}
return connectionPromise;
};
}());
var Hare = comb.define(_Options, {

@@ -58,0 +62,0 @@

@@ -31,14 +31,14 @@ "use strict";

__getQueue: function __getQueue() {
var queueName = this.queueName;
var queueName = this.queueName, self = this;
if (!this.__queuePromise) {
this.__queuePromise = this.getConnection().chain(function connectCb(connection) {
var ret = new Promise();
connection.queue(queueName, this.options, function (queue) {
queueName = this.queueName = queue.name;
queue.bind(this.get("exchange"), this.get("routingKey") || queue.name);
this.__queue = queue;
connection.queue(queueName, self.options, function (queue) {
queueName = self.queueName = queue.name;
queue.bind(self.get("exchange"), self.get("routingKey") || queue.name);
self.__queue = queue;
ret.callback(queue);
}.bind(this));
});
return ret;
}.bind(this));
});
}

@@ -108,5 +108,7 @@ return this.__queuePromise;

subscribe: function subscribe(listener) {
return this.__getQueue().then(function (queue) {
this.__subscribe(queue, listener);
}.bind(this));
var self = this;
return this.__getQueue().chain(function (queue) {
self.__subscribe(queue, listener);
return queue;
});
},

@@ -113,0 +115,0 @@

{
"name": "hare",
"version": "0.0.15",
"version": "0.2.0",
"description": "Wrapper around amqp to make common patterns easier",

@@ -16,3 +16,3 @@ "main": "index.js",

"dependencies": {
"amqp": "~0.1.3",
"amqp": "~0.2.0",
"comb": "~0.2.3"

@@ -19,0 +19,0 @@ },

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