Comparing version 0.0.2 to 0.0.3
@@ -58,2 +58,3 @@ 'use strict'; | ||
* @param {String} subject | ||
* @param {String} payload | ||
* | ||
@@ -79,2 +80,3 @@ * @returns {Promise} | ||
* @param {String} subject | ||
* @param {String} payload | ||
* | ||
@@ -90,4 +92,8 @@ * @returns {Promise} | ||
return new Promise(function (resolve, reject) { | ||
_this3.connection.publish(subject, payload, function () { | ||
resolve(); | ||
_this3.connection.publish(subject, payload, function (error) { | ||
if (error) { | ||
reject(error); | ||
} else { | ||
resolve(); | ||
} | ||
}); | ||
@@ -97,2 +103,17 @@ }); | ||
}, { | ||
key: 'flush', | ||
value: function flush() { | ||
var _this4 = this; | ||
return new Promise(function (resolve, reject) { | ||
_this4.connection.flush(function (error) { | ||
if (error) { | ||
reject(error); | ||
} else { | ||
resolve(); | ||
} | ||
}); | ||
}); | ||
} | ||
}, { | ||
key: 'close', | ||
@@ -99,0 +120,0 @@ value: function close() { |
{ | ||
"name": "natsify", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"description": "A nuts wrapper with promises", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -35,2 +35,3 @@ import { connect } from 'nats' | ||
* @param {String} subject | ||
* @param {String} payload | ||
* | ||
@@ -51,2 +52,3 @@ * @returns {Promise} | ||
* @param {String} subject | ||
* @param {String} payload | ||
* | ||
@@ -57,4 +59,8 @@ * @returns {Promise} | ||
return new Promise((resolve, reject) => { | ||
this.connection.publish(subject, payload, () => { | ||
resolve() | ||
this.connection.publish(subject, payload, error => { | ||
if (error) { | ||
reject(error) | ||
} else { | ||
resolve() | ||
} | ||
}) | ||
@@ -64,2 +70,14 @@ }) | ||
flush () { | ||
return new Promise((resolve, reject) => { | ||
this.connection.flush(error => { | ||
if (error) { | ||
reject(error) | ||
} else { | ||
resolve() | ||
} | ||
}) | ||
}) | ||
} | ||
close () { | ||
@@ -66,0 +84,0 @@ this.connection.close() |
6330
193