export class TopicParser { private readonly _type: string private _topicArray: string[] constructor (topic: string) { const topicArray = topic.split('/') this._topicArray = topicArray this._type = topicArray[1] } public get topicArray(): string[] { return this._topicArray } public get type (): string { return this._type } } export class MessageTopicParser extends TopicParser { constructor(topic: string) { super(topic) } public get messageType(): string { return this.topicArray[3] } public get childDeviceId(): string | undefined { return this.topicArray[4] } }