UNPKG

diffusion

Version:

Diffusion JavaScript client

36 lines (28 loc) 937 B
var inherits = require('inherits'); var regex = require('util/regex'); var utils = require('topics/topic-path-utils'); var TopicSelector = require('../../selectors/topic-selector'); var DQ = utils.DescendantQualifier; function FullPathSelector(components) { switch (components.qualifier) { case DQ.MATCH : this.regex = regex(components.base); break; case DQ.DESCENDANTS_OF_MATCH : this.regex = regex(components.base + "/.+"); break; case DQ.MATCH_AND_DESCENDANTS : this.regex = regex(components.base + "(?:$|/.+)"); break; } TopicSelector.call( this, components.type, components.prefix, components.expression); } inherits(FullPathSelector, TopicSelector); FullPathSelector.prototype.doSelects = function (topicPath) { return this.regex(topicPath); }; module.exports = FullPathSelector;