Ready to take your JavaScript development to the next level? Meet npm Enterprise - the ultimate in enterprise JavaScript. Learn more »

mqtt-wildcard

3.0.9 • Public • Published

mqtt-wildcard

NPM version Dependency Status Build Status Coverage Status XO code style License

Match a MQTT Topic against Wildcards

Install and Usage

$ npm install mqtt-wildcard
var mqttWildcard = require('mqtt-wildcard');

Alternatively you can use bower to install mqtt-wildcard, AMD is also supported.

API

array|null mqttWildcard (string topic, string wildcard)

Returns null if not matched, otherwise an array containing the wildcards contents will be returned.

Examples:

mqttWildcard('test/foo/bar', 'test/foo/bar'); // []
mqttWildcard('test/foo/bar', 'test/+/bar'); // ['foo']
mqttWildcard('test/foo/bar', 'test/#'); // ['foo/bar']
mqttWildcard('test/foo/bar/baz', 'test/+/#'); // ['foo', 'bar/baz']
mqttWildcard('test/foo/bar/baz', 'test/+/+/baz'); // ['foo', 'bar']
 
mqttWildcard('test', 'test/#'); // []
mqttWildcard('test/', 'test/#'); // ['']
 
mqttWildcard('test/foo/bar', 'test/+'); // null
mqttWildcard('test/foo/bar', 'test/nope/bar'); // null

License

MIT (c) 2017 Sebastian Raff

install

npm i mqtt-wildcard

Downloadsweekly downloads

185

version

3.0.9

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability