Nutritious Pumpkin Masses

    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

    1,181

    Version

    3.0.9

    License

    MIT

    Last publish

    Collaborators

    • hobbyquaker