/myqlobber

Node.js globbing for amqp-like topics

Primary LanguageHTMLMIT LicenseMIT

this is a fork of : https://github.com/davedoesdev/qlobber

This version does not handle values attached to topics. You define topics that can match and a boolean if got from match() function. Does not support wildcard on multiple level (#).

It handles a wildcard single level on both the topics add and the topic to match.

Examples :

var matcher = new Qlobber(); matcher.add('.orange.'); matcher.add('..rabbit'); matcher.add('foo.one.bar'); assert.deepEqual( [ 'quick.orange.rabbit', 'lazy.orange.elephant', 'lazy.pink.rabbit', 'lazy.brown.fox', 'orange', 'foo.one.bar', 'foo.two.bar', 'foo.*.bar' ].map(function (topic) { return matcher.match(topic); }), [ true, true, true, false, false, true, false, true ] );

API

Source: lib/qlobber.js

Qlobber([options])

Creates a new qlobber.

Parameters:

  • {Object} [options] Configures the qlobber. Use the following properties:
    • {String} separator The character to use for separating words in topics. Defaults to '.'. MQTT uses '/' as the separator, for example.

    • {String} wildcard The character to use for matching exactly one word in a topic. Defaults to '*'. MQTT uses '+', for example.

Go: TOC

Qlobber.prototype.add(topic)

Add a topic matcher to the qlobber.

Parameters:

  • {String} topic The topic to match against.

Return:

{Qlobber} The qlobber (for chaining).

Go: TOC | Qlobber.prototype

Qlobber.prototype.remove(topic)

Remove a topic matcher from the qlobber.

Parameters:

  • {String} topic The topic that's being matched against.

Return:

{Qlobber} The qlobber (for chaining).

Go: TOC | Qlobber.prototype

Qlobber.prototype.match(topic)

Match a topic.

Parameters:

  • {String} topic The topic to match against.

Return:

{Boolean} True if topic matches. False otherwise

Go: TOC | Qlobber.prototype

Qlobber.prototype.clear()

Reset the qlobber.

Removes all topic matchers from the qlobber.

Return:

{Qlobber} The qlobber (for chaining).

Go: TOC | Qlobber.prototype

—generated by apidox