Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hobbyquaker/mqtt-wildcard
Match a MQTT Topic against Wildcards
https://github.com/hobbyquaker/mqtt-wildcard
match mqtt regex topic wildcard
Last synced: 2 months ago
JSON representation
Match a MQTT Topic against Wildcards
- Host: GitHub
- URL: https://github.com/hobbyquaker/mqtt-wildcard
- Owner: hobbyquaker
- License: mit
- Created: 2017-04-30T15:06:41.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-05-09T20:49:34.000Z (over 6 years ago)
- Last Synced: 2024-11-06T07:03:48.604Z (3 months ago)
- Topics: match, mqtt, regex, topic, wildcard
- Language: JavaScript
- Size: 15.6 KB
- Stars: 14
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# mqtt-wildcard
[![NPM version](https://badge.fury.io/js/mqtt-wildcard.svg)](http://badge.fury.io/js/mqtt-wildcard)
[![Dependency Status](https://img.shields.io/gemnasium/hobbyquaker/mqtt-wildcard.svg?maxAge=2592000)](https://gemnasium.com/github.com/hobbyquaker/mqtt-wildcard)
[![Build Status](https://travis-ci.org/hobbyquaker/mqtt-wildcard.svg?branch=master)](https://travis-ci.org/hobbyquaker/mqtt-wildcard)
[![Coverage Status](https://coveralls.io/repos/github/hobbyquaker/mqtt-wildcard/badge.svg?branch=master)](https://coveralls.io/github/hobbyquaker/mqtt-wildcard?branch=master)
[![XO code style](https://img.shields.io/badge/code_style-XO-5ed9c7.svg)](https://github.com/sindresorhus/xo)
[![License][mit-badge]][mit-url]> Match a MQTT Topic against Wildcards
## Install and Usage
```
$ npm install mqtt-wildcard
``````javascript
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:
```javascript
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](https://github.com/hobbyquaker)
[mit-badge]: https://img.shields.io/badge/License-MIT-blue.svg?style=flat
[mit-url]: LICENSE