Helper function that tries to match a channel with each subscription it returns undefined if no match is found
352098
function matchesWildcard (subscriptions, channel) {
    var i;
    var subs = Object.keys(subscriptions);
    for (i=0; i < subs.length; i++) {
        if (matchesFilter(subs[i], channel)) {
            return subs[i];
        }
    }
    return undefined;
}
875617
function(client, subscriptions, channel, callback, done_callback) {
    if (subscriptions[channel]===undefined)
        return;
    subscriptions[channel].splice(subscriptions[channel].indexOf(callback), 1);
    if (subscriptions[channel].length===0) {
        delete subscriptions[channel];
        client.unsubscribe(channel, function() {
            // If there is a done_callback defined, execute it
            if (done_callback!==undefined) done_callback();
        });
    }
}
1043273
function match(source, cases, isExec) {
      if (!isObj(cases)) throwErr('obj');
      if (isUdf(isExec)) isExec = true;
      var symbol = '__@fnMatch__';
      if (has(cases, source)) {
        symbol = source;
      } else if (has(cases, 'default')) {
        symbol = 'default';
      }
      var matched = cases[symbol];
      if (matched === '@next') {
        var ks = keys(cases), i = ks.indexOf(symbol) - 1;
        while (++i < ks.length) if (cases[ks[i]] !== '@next') { matched = cases[ks[i]]; break; }
      }
      if (isExec && isFun(matched)) {
        return len(matched) ? matched(source) : matched();
      } else {
        return matched === '@next' ? UDF : matched;
      }
    }
515782
def select_subscription(subs_code, subscriptions):
    
    if subs_code and subscriptions:
        for subs in subscriptions:
            if (subs.subscription_code == subs_code):
                return subs
    return None
587543
function lookupSpecMatch(lookup, spec) {
  // Direct match
  if (lookup[spec]) {
    return lookup[spec];
  }

  // Close match
  var shortSpec = spec.replace(/@\D/g,'@');
  if (lookup[shortSpec]) {
    return lookup[shortSpec];
  }

  // Check for Semver valid match
  var lastIndex = spec.lastIndexOf('@');
  var myName = spec.substring(0, lastIndex);
  var myVersion = spec.substring(lastIndex + 1);
  for(var k in lookup) {
    lastIndex = k.lastIndexOf('@');
    var yourName = k.substring(0, lastIndex);
    var yourVersion = k.substring(lastIndex + 1);
    if (myName == yourName && semver.valid(yourVersion) && semver.satisfies(yourVersion, myVersion)) {
      return lookup[k];
    }
  }
  return undefined;
}
898527
def pubsub_channels(self, pattern=None):
        """"""
        args = [b'PUBSUB', b'CHANNELS']
        if pattern is not None:
            args.append(pattern)
        return self.execute(*args)
252385
function publish(conn, channel, message) {
  var c = 0
    , indices = []
    , len
    , k
    , re;

  // exact channel match
  for(k in this._channels) {
    // found the channel
    if(k === channel) {
      indices = this._channels[k].slice(0);
      this.emit(
        PUBSUB.PUBLISH, conn, channel, indices,
          [PUBSUB.MESSAGE, channel, message]);
      break;
    }
  }

  len = indices.length;

  // reset indices for patterns
  // required to prevent channel subscribers
  // from also receiving pmessage events
  indices = [];

  // test against pattern channels
  for(k in this._patterns) {
    // pattern should be pre-compiled
    re = this._patterns[k].re;
    if(re.test(channel)) {
      indices = indices.concat(this._patterns[k]);
      this.emit(
        PUBSUB.PUBLISH, conn, channel, indices,
          [PUBSUB.PMESSAGE, k, channel, message]);
    }
  }

  len += indices.length;

  return len;
}
1232219
function _observeSubscriptionSyncEvents(args) {
  var rtm = args.rtm;
  var filterFn = args.filterFn;

  rtm.on('subscription-created', function(subscription) {
    if (subscription.allowRead !== true) return;

    filterFn(subscription).then(function(ok) {
      if (ok) {
        rtm.subscribe({channel: subscription.channelId});
      }
    });
  });

  rtm.on('subscription-deleted', function(subscription) {
    rtm.unsubscribe({channel: subscription.channelId});
  });

  rtm.on('subscription-updated', function(subscription) {
    if (subscription.allowRead === false) {
      return rtm.unsubscribe({channel: subscription.channelId});
    }
    filterFn(subscription).then(function(ok) {
      if (ok) {
        rtm.subscribe({channel: subscription.channelId});
      }
    });
  });
}
670984
function psubscribe(conn, channels) {
  return this.doSubscribe(
    PUBSUB.PSUBSCRIBE,
    PUBSUB.PATTERNS,
    this._patterns, conn, channels);
}
1190248
function (area, layer) {
	
	// check if layer exists
	if (l_layers.hasOwnProperty(layer) === false)
		return [];
	
	// get all current subscriptions at this layer
	var subs = l_layers[layer];
	
	// prepare list of connection of subscribers matching / covering the area
	var connections = [];
	
	// check each subscription to see if it overlaps with the given area
	for (var id in subs) {
		var subscription = subs[id];
		
		// check for overlaps (distance between the two centers is less than sum of radii)
		if (l_dist(subscription, para) <= (subscription.r + para.r))
			connections.push(subscription.conn);
	}
	
	return connections;
}
485597
function subscribeNode (client, subscriptions, channel, callback, done_callback) {
    if (subscriptions[channel]===undefined) {
        subscriptions[channel] = [callback];
        client.subscribe(channel, {qos: 0}, function() {
            // If there is a done_callback defined, execute it
            if (done_callback!==undefined) done_callback();
        });
    } else {
        subscriptions[channel].push(callback);
    }
}
105161
function matchSubInternal(el, match) {
        var matchImmediateRet = matchImmediate(el, match);
        if (matchImmediateRet === true) {
            return true;
        } else {
            el = matchImmediateRet.el;
            match = matchImmediateRet.match;
            while (el) {
                if (matchSub(el, match)) {
                    return true;
                }
                el = dir(el, relativeExpr[match.nextCombinator].dir);
            }
            return false;
        }
    }
422706
function (h, c) {
        var len = c.length;
        var i = len;
        var f = function () {
            if (!(--i)) h();
        };
        for (var j = 0; j < len; j++) {
            if (c[j].state === 0) {
                throw Error('Can only use join with sticky channels.');
            }
            c[j].subscribe(f);
        }
        if (!len) h();
    }
7252
function matchesCustom(ctx, opts) {
  if (opts.custom) {
    return opts.custom.call(ctx);
  }
  return false;
}
593632
function newChannel() {
  let chan = new Channel();
  let result = chan.send.bind(chan);
  result._inst = chan;
  return result;
}
1213609
function find(list, match) {
	  for (var i = 0; i < list.length; i++) {
	    if (match(list[i])) {
	      return list[i];
	    }
	  }
	  return undefined;
	}
529194
def get_subscriptions_channel(self, search_channel):
        
        data = self.get_clients()
        clients = []
        for client in data:
            if 'subscriptions' in client:
                if isinstance(client['subscriptions'], list):
                    if search_channel in client['subscriptions']:
                        clients.append(client['name'])
                else:
                    if search_channel == client['subscriptions']:
                        clients.append(client['name'])
        return clients