# @mangar2/topicmap

> maps topics from internal representation to external representation

Latest version **1.0.1** (published 2020-12-10) · LGPL-3.0-or-later license · 0 weekly downloads

## Install

```sh
npm install @mangar2/topicmap
pnpm add @mangar2/topicmap
yarn add @mangar2/topicmap
bun add @mangar2/topicmap
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2020-12-10 |
| First published | 2020-01-25 |
| Weekly downloads | 0 |
| License | LGPL-3.0-or-later |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 10.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Volker Böhm |
| Maintainers | mangar2 |
| Keywords | topic, pattern, map |

## Links

- npm: https://www.npmjs.com/package/@mangar2/topicmap
- Repository: https://github.com/Mangar2/yaha/tree/master/node_modules/@mangar2/topicmap
- Homepage: https://github.com/Mangar2/yaha.git
- npm.io page: https://npm.io/package/@mangar2/topicmap

## Dependencies (2)

- [@mangar2/types](https://npm.io/package/@mangar2/types.md) latest
- [@mangar2/topicmatch](https://npm.io/package/@mangar2/topicmatch.md) latest

## Recent versions

- 1.0.1 (latest) — 2020-12-10
- 1.0.0 — 2020-01-25

## README

<!-- This file is generated by jsmddoc version 0.1 -->

# Abstract

## Contents

- [Meta](#Meta)
- [Class TopicMap](#Class-TopicMap)
  - [Parameters](#TopicMap-Parameters)
  - [Methods](#TopicMap-Methods)
    - [mapExternalToInternal](#mapExternalToInternal)
    - [mapInternalToExternal](#mapInternalToExternal)

## 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

```javascript
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 |

---
_Source: https://npm.io/package/@mangar2/topicmap · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
