@silverwind/ioredis-mock
Version:
This library emulates ioredis by performing all operations in-memory.
30 lines (22 loc) • 723 B
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.subscribe = subscribe;
var _channelSubscription = require("../commands-utils/channel-subscription");
function subscribe(...args) {
args.forEach(chan => {
if (!this.channels.instanceListeners) {
this.channels.instanceListeners = new Map();
}
(0, _channelSubscription.subscribeToChannel)(this, chan, this.channels);
});
if (!this.channels.instanceListeners) {
return 0;
}
const numberOfSubscribedChannels = (0, _channelSubscription.getSubscribedChannels)(this, this.channels).length;
if (numberOfSubscribedChannels > 0) {
this.subscriberMode = true;
}
return numberOfSubscribedChannels;
}