@mangar2/topicmap
v1.0.1
Published
maps topics from internal representation to external representation
Downloads
4
Readme
Abstract
Contents
Meta
Class TopicMap
new TopicMap(configuration)
Creates a class to map topics from internal to external representation and vice versa if there is a matching mapping rule in configuration . It keeps unchanged if there is no mapping rule
Example
const configuration =
fs20: {
'fs20/2111': 'ground/livingroom/zwave/switch/multimedia/set'
},
location: {
'location/33/#': 'first/bedroom/main/#'
}
const topicMap = new topicMap(configuration)
const map = topicMap('location/33/a/b') // returns 'first/bedroom/main/a/b'
const map = topicMap('anything/not/mapped') // returns 'anything/not/mapped'
TopicMap Parameters
| Name | Type | Description |
| ---------- | ------------ | ----------------- |
| configuration
| Object
| mapping configuration with topic : map pairs that might be organized in trees like { 1 : { topic : map , . . . } , 2 : { topic : map , . . . } } | |
TopicMap Methods
mapExternalToInternal
mapExternalToInternal (topic) => {string}
Maps a topic from external representation to internal representation
mapExternalToInternal Parameters
| Name | Type | Description |
| ---------- | ------------ | ----------------- |
| topic
| string
| external topic to map | |
mapExternalToInternal returns
| Type | Description |
| ---- | ----------- |
| string
| internal topic |
mapInternalToExternal
mapInternalToExternal (topic) => {string}
Maps a topic from internal representation to external representation
mapInternalToExternal Parameters
| Name | Type | Description |
| ---------- | ------------ | ----------------- |
| topic
| string
| internal topic to map | |
mapInternalToExternal returns
| Type | Description |
| ---- | ----------- |
| string
| external topic |