nsq-publisher
Advanced tools
Comparing version 1.0.0 to 1.0.2
@@ -21,3 +21,3 @@ const Promise = require('bluebird-tools'); | ||
if (!callback) { | ||
return new Promise((resolve, reject) => { | ||
return Promise.when(() => !this._topicCreated, () => new Promise((resolve, reject) => { | ||
request.post(this.topicUrl, (err) => { | ||
@@ -30,5 +30,9 @@ if (err) { | ||
}); | ||
}); | ||
})); | ||
} | ||
if (this._topicCreated) { | ||
callback(); | ||
return; | ||
} | ||
request.post(this.topicUrl, (err) => { | ||
@@ -46,3 +50,3 @@ if (err) { | ||
if (!callback) { | ||
return Promise.when(() => this._topicCreated && this.autoCreate, this.createTopic) | ||
return Promise.when(() => this.autoCreate, this.createTopic) | ||
.then(() => new Promise((resolve, reject) => { | ||
@@ -49,0 +53,0 @@ const nsqWriter = new nsq.Writer(this.dataUrl, this.dataTcpPort); |
{ | ||
"name": "nsq-publisher", | ||
"version": "1.0.0", | ||
"version": "1.0.2", | ||
"description": "Simple way to create topics and publish messages in NSQ", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -0,0 +0,0 @@ # NSQ Publisher |
@@ -87,6 +87,16 @@ const Promise = require('bluebird-tools'); | ||
suite('#createTopic', function() { | ||
test('calls the request.post once', (done) => { | ||
test('never calls the request.post when _createTopic is true', (done) => { | ||
const publisher = new NsqPublisher({}); | ||
publisher._topicCreated = true; | ||
publisher.createTopic() | ||
.then(() => { | ||
expect(requestMock.post.called).to.be.false; | ||
done(); | ||
}) | ||
.catch(err => done(err)); | ||
}); | ||
test('calls the request.post once when _createTopic is false', (done) => { | ||
const publisher = new NsqPublisher({}); | ||
publisher.createTopic() | ||
.then(() => { | ||
expect(requestMock.post.calledOnce).to.be.true; | ||
@@ -93,0 +103,0 @@ done(); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
22039
343
0