Comparing version 4.4.1 to 4.5.0
@@ -30,2 +30,3 @@ 'use strict' | ||
this.current = 0 | ||
this._doing = false | ||
this._matcher = new Qlobber({ | ||
@@ -49,2 +50,4 @@ match_empty_levels: opts.matchEmptyLevels, | ||
that._do(message, callback) | ||
} else { | ||
that._doing = false | ||
} | ||
@@ -97,2 +100,6 @@ } | ||
this._messageCallbacks.push(cb) | ||
if (!this._doing) { | ||
process.emitWarning('MqEmitter leak detected', { detail: 'For more info check: https://github.com/mcollina/mqemitter/pull/94' }) | ||
this._released() | ||
} | ||
} else { | ||
@@ -113,2 +120,3 @@ this._do(message, cb) | ||
MQEmitter.prototype._do = function (message, callback) { | ||
this._doing = true | ||
const matches = this._matcher.match(message.topic) | ||
@@ -122,4 +130,4 @@ | ||
function noop () {} | ||
function noop () { } | ||
module.exports = MQEmitter |
{ | ||
"name": "mqemitter", | ||
"version": "4.4.1", | ||
"version": "4.5.0", | ||
"description": "An Opinionated Message Queue with an emitter-style API", | ||
@@ -47,6 +47,6 @@ "main": "mqemitter.js", | ||
"devDependencies": { | ||
"@types/node": "^14.0.26", | ||
"@types/node": "^16.11.1", | ||
"@typescript-eslint/eslint-plugin": "^2.19.2", | ||
"@typescript-eslint/parser": "^2.19.2", | ||
"markdownlint-cli": "^0.26.0", | ||
"markdownlint-cli": "^0.29.0", | ||
"nyc": "^15.0.0", | ||
@@ -57,3 +57,3 @@ "pre-commit": "^1.2.2", | ||
"tape": "^5.0.1", | ||
"tsd": "^0.14.0", | ||
"tsd": "^0.18.0", | ||
"typescript": "^4.0.2" | ||
@@ -60,0 +60,0 @@ }, |
@@ -38,2 +38,29 @@ 'use strict' | ||
test('queue released when full', function (t) { | ||
t.plan(21) | ||
const e = mq({ concurrency: 1 }) | ||
e.on('hello 1', function (message, cb) { | ||
t.ok(true, 'message received') | ||
setTimeout(cb, 10) | ||
}) | ||
function onSent () { | ||
t.ok(true, 'message sent') | ||
} | ||
for (let i = 0; i < 9; i++) { | ||
e._messageQueue.push({ topic: 'hello 1' }) | ||
e._messageCallbacks.push(onSent) | ||
e.current++ | ||
} | ||
e.emit({ topic: 'hello 1' }, onSent) | ||
process.once('warning', function (warning) { | ||
t.equal(warning.message, 'MqEmitter leak detected', 'warning message') | ||
}) | ||
}) | ||
test('without any listeners and a callback', function (t) { | ||
@@ -40,0 +67,0 @@ const e = mq() |
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
36404
828