Comparing version 0.1.0 to 0.1.1
@@ -56,3 +56,2 @@ /* | ||
assert(message) | ||
assert(cb) | ||
@@ -93,2 +92,6 @@ if (this.concurrency > 0 && this.current >= this.concurrency) { | ||
if (matches.length === 0) { | ||
return this._next(receiver) | ||
} | ||
receiver.num = matches.length | ||
@@ -121,3 +124,5 @@ receiver.callback = callback | ||
if (that.num === 0) { | ||
that.callback() | ||
if (that.callback) { | ||
that.callback() | ||
} | ||
mq._next(that) | ||
@@ -124,0 +129,0 @@ } |
{ | ||
"name": "mqemitter", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"description": "An Opinionated Message Queue with an emitter-style API", | ||
@@ -10,3 +10,21 @@ "main": "index.js", | ||
"pre-commit": ["test"], | ||
"author": "", | ||
"website": "https://github.com/mcollina/mqemitter", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/mcollina/mqemitter.git" | ||
}, | ||
"bugs": { | ||
"url": "http://github.com/mcollina/mqemitter/issues" | ||
}, | ||
"author": "Matteo Collina <hello@matteocollina.com>", | ||
"keywords": [ | ||
"emitter", | ||
"events", | ||
"message queue", | ||
"mq", | ||
"publish", | ||
"subscribe", | ||
"pub", | ||
"sub" | ||
], | ||
"license": "ISC", | ||
@@ -13,0 +31,0 @@ "devDependencies": { |
34
test.js
@@ -6,3 +6,3 @@ | ||
test('support on and emit', function(t) { | ||
t.plan(1) | ||
t.plan(2) | ||
@@ -16,2 +16,3 @@ var e = mq() | ||
e.on('hello world', function(message, cb) { | ||
t.equal(e.current, 1, 'number of current messages') | ||
t.equal(message, expected) | ||
@@ -89,3 +90,3 @@ cb() | ||
test('queue concurrency', function(t) { | ||
t.plan(2) | ||
t.plan(3) | ||
@@ -101,2 +102,4 @@ var e = mq({ concurrency: 1 }) | ||
t.equal(e.concurrency, 1) | ||
e.on('hello 1', function(message, cb) { | ||
@@ -171,1 +174,28 @@ setTimeout(cb, 5) | ||
}) | ||
test('without a callback on emit', function(t) { | ||
var e = mq() | ||
, expected = { | ||
topic: 'hello world' | ||
, payload: { my: 'message' } | ||
} | ||
e.on('hello world', function(message, cb) { | ||
cb() | ||
t.end() | ||
}) | ||
e.emit(expected) | ||
}) | ||
test('without any listeners', function(t) { | ||
var e = mq() | ||
, expected = { | ||
topic: 'hello world' | ||
, payload: { my: 'message' } | ||
} | ||
e.emit(expected) | ||
t.equal(e.current, 0, 'reset the current messages trackers') | ||
t.end() | ||
}) |
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
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
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
No contributors or author data
MaintenancePackage does not specify a list of contributors or an author in package.json.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
430535
13
256
0
0
4