Closed mcfitz2 closed 3 years ago
This PR adds a new method to the mqtt_regex result that allows the user to build a valid MQTT topic using a topic pattern and a set of values.
Usage is as follows:
var topic = mqtt_regex("/feeder/+feederId/needInit") var params = {"feederId":"feeder-1"} topic.format(params)
This should return a formatted MQTT topic that looks like /feeder/feeder-1/needInit
/feeder/feeder-1/needInit
Released in 1.1.0. Also added a thing to expand the array for the # params if one exists.
#
e.g.
const {format} = mqtt_pattern('foo/#bar') format({bar: [1,2,3]}) === 'foo/1/2/3'
This PR adds a new method to the mqtt_regex result that allows the user to build a valid MQTT topic using a topic pattern and a set of values.
Usage is as follows:
This should return a formatted MQTT topic that looks like
/feeder/feeder-1/needInit