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

jackrabbit

Package Overview
Dependencies
Maintainers
1
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jackrabbit - npm Package Compare versions

Comparing version 4.0.3 to 4.1.0

24

lib/exchange.js

@@ -76,3 +76,7 @@ var amqp = require('amqplib/callback_api');

var keys = options.keys || [options.key];
keys.forEach(bindKey);
bindKeys(keys)
.then(function emitBoundEvent(res) {
newQueue.emit('bound')
})
.catch(bail);
}

@@ -91,8 +95,16 @@ });

function bindKey(key) {
channel.bindQueue(newQueue.name, emitter.name, key, {}, onBind);
}
// return a promise when all keys are bound
function bindKeys(keys) {
return Promise.all(keys.map(bindKey));
function onBind(err, ok) {
if (err) return bail(err);
// returns a promise when a key is bound
function bindKey(key) {
var deferred = Promise.defer();
channel.bindQueue(newQueue.name, emitter.name, key, {}, function onBind(err, ok) {
if (err) return deferred.reject(err);
return deferred.resolve(ok);
});
return deferred.promise;
}
}

@@ -99,0 +111,0 @@ }

{
"name": "jackrabbit",
"version": "4.0.3",
"version": "4.1.0",
"description": "Easy RabbitMQ for node",

@@ -5,0 +5,0 @@ "readme": "https://github.com/hunterloftis/jackrabbit/blob/master/readme.md",

@@ -53,1 +53,9 @@ # Jackrabbit

```
If using Docker-Machine on OSX:
```
$ docker-machine start
$ eval "$(docker-machine env default)"
$ docker-compose run jackrabbit npm test
```
var assert = require('chai').assert;
var amqp = require('amqplib/callback_api');
var exchange = require('../lib/exchange');
var uuid = require('node-uuid');

@@ -83,7 +84,36 @@ describe('exchange', function() {

});
describe('with key bindings', function () {
before(function(done) {
amqp.connect(process.env.RABBIT_URL, function(err, conn) {
assert.ok(!err);
this.exchange = exchange('test.topic.bindings', 'topic')
.connect(conn)
.once('connected', done);
}.bind(this));
});
it('emits a "bound" event when all routing keys have been bound to the queue', function (done) {
var keys = 'abcdefghijklmnopqrstuvwxyz'.split('');
var finalKey = keys[keys.length - 1];
var queue = this.exchange.queue({ keys: keys });
var message = uuid.v4();
queue.consume(function (data, ack, nack, msg) {
assert.equal(message, data);
assert.equal(msg.fields.routingKey, finalKey);
ack();
done();
});
queue.once('bound', function () {
this.exchange.publish(message, { key: finalKey });
}.bind(this));
});
});
});
describe('#publish', function() {
});
});
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