amqper
Advanced tools
Comparing version 0.5.1 to 0.5.2
@@ -117,25 +117,32 @@ "use strict"; | ||
close(cb) { | ||
if (this.closing || this.closed) { | ||
if (cb) cb(); | ||
return PromiseA.resolve(); | ||
close(delay, cb) { | ||
if (typeof delay === 'function') { | ||
cb = delay; | ||
delay = null; | ||
} | ||
return this.$promise.finally(() => { | ||
this.closing = true; | ||
const that = this; | ||
return close_connection(this.conn).then(function () { | ||
return PromiseA.all(PromiseA.map(that.routers, function (router) { | ||
return router.connection.then(function (conn) { | ||
if (conn === that.conn) return; | ||
return close_connection(conn); | ||
}); | ||
})); | ||
}).then(function () { | ||
that.routers = []; | ||
that.closed = true; | ||
that.closing = false; | ||
if (cb) cb(); | ||
}); | ||
if (this.closing) { | ||
return this.closing.asCallback(cb); | ||
} | ||
const p = delay ? PromiseA.fromCallback(cb => setTimeout(cb, parseInt(delay))) : PromiseA.resolve(); | ||
return this.closing = p.then(() => { | ||
return this.$promise | ||
.then() | ||
.then(() => { | ||
return PromiseA.all(PromiseA.map(this.routers, (router) => { | ||
return router.connection.then((conn) => { | ||
if (conn === this.conn) return; | ||
return close_connection(conn); | ||
}); | ||
})); | ||
}) | ||
.then(() => close_connection(this.conn)) | ||
.then(() => { | ||
this.routers = []; | ||
this.closed = true; | ||
this.closing = null; | ||
}) | ||
.asCallback(cb); | ||
}); | ||
}; | ||
} | ||
} | ||
@@ -142,0 +149,0 @@ |
{ | ||
"name": "amqper", | ||
"version": "0.5.1", | ||
"version": "0.5.2", | ||
"description": "A simple and elegant AMQP client for node based on amqplib.", | ||
@@ -5,0 +5,0 @@ "homepage": "https://github.com/taoyuan/amqper", |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
84673
501
0