Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
var redis = require('redis');
var PubSub = require('sharedb').PubSub;
// Redis pubsub driver for ShareDB.
//
// The redis driver requires two redis clients (a single redis client can't do
// both pubsub and normal messaging). These clients will be created
// automatically if you don't provide them.
function RedisPubSub(options) {
if (!(this instanceof RedisPubSub)) return new RedisPubSub(options);
PubSub.call(this, options);
options || (options = {});
this.client = options.client || redis.createClient(options);
// Redis doesn't allow the same connection to both listen to channels and do
// operations. Make an extra redis connection for subscribing with the same
// options if not provided