mqemitter-redis
Advanced tools
Comparing version 4.1.0 to 4.2.0
@@ -199,1 +199,29 @@ 'use strict' | ||
module.exports = MQEmitterRedis | ||
function MQEmitterRedisPrefix (pubSubPrefix, options) { | ||
MQEmitterRedis.call(this, options) | ||
this._pubSubPrefix = pubSubPrefix | ||
this._sym_proxiedCallback = Symbol('proxiedCallback') | ||
} | ||
inherits(MQEmitterRedisPrefix, MQEmitterRedis) | ||
MQEmitterRedisPrefix.prototype.on = function (topic, cb, done) { | ||
const t = this._pubSubPrefix + topic | ||
cb[this._sym_proxiedCallback] = function (packet, cbcb) { | ||
const t = packet.topic.slice(this._pubSubPrefix.length) | ||
const p = { ...packet, topic: t } | ||
return cb.call(this, p, cbcb) | ||
}.bind(this) | ||
return MQEmitterRedis.prototype.on.call(this, t, cb[this._sym_proxiedCallback], done) | ||
} | ||
MQEmitterRedisPrefix.prototype.removeListener = function (topic, func, done) { | ||
const t = this._pubSubPrefix + topic | ||
const f = func[this._sym_proxiedCallback] | ||
return MQEmitterRedis.prototype.removeListener.call(this, t, f, done) | ||
} | ||
MQEmitterRedisPrefix.prototype.emit = function (packet, done) { | ||
const t = this._pubSubPrefix + packet.topic | ||
const p = { ...packet, topic: t } | ||
return MQEmitterRedis.prototype.emit.call(this, p, done) | ||
} | ||
module.exports.MQEmitterRedisPrefix = MQEmitterRedisPrefix |
{ | ||
"name": "mqemitter-redis", | ||
"version": "4.1.0", | ||
"version": "4.2.0", | ||
"description": "Redis-based MQEmitter", | ||
@@ -5,0 +5,0 @@ "main": "mqemitter-redis.js", |
@@ -1,2 +0,2 @@ | ||
mqemitter-redis [![Build Status](https://travis-ci.org/mcollina/mqemitter-redis.png)](https://travis-ci.org/mcollina/mqemitter-redis) | ||
mqemitter-redis ![ci](https://github.com/mcollina/mqemitter/workflows/ci/badge.svg) | ||
=============== | ||
@@ -3,0 +3,0 @@ |
@@ -12,2 +12,7 @@ 'use strict' | ||
abstractTests({ | ||
builder: function (opts) { return new redis.MQEmitterRedisPrefix('some_prefix/', opts) }, | ||
test: test | ||
}) | ||
function noop () {} | ||
@@ -14,0 +19,0 @@ |
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
13717
10
303
0