function getTag
getTag(words: string[]): string | undefined

Extracts the tag value from a sentence (array of words)

Searches for the .tag attribute in the word array and returns its value. Tags are used for multiplexing multiple concurrent requests over a single connection.

Examples

Extract tag from sentence

import { assertEquals } from "@std/assert";
import { getTag } from "@hertzg/routeros-api/utils/tag";

const words = ["/interface/print", ".tag=abc123"];
const tag = getTag(words);
assertEquals(tag, "abc123");

No tag present

import { assertEquals } from "@std/assert";
import { getTag } from "@hertzg/routeros-api/utils/tag";

const words = ["/interface/print"];
const tag = getTag(words);
assertEquals(tag, undefined);

Parameters

words: string[]

Array of words from a sentence

Return Type

string | undefined

The tag value if present, undefined otherwise

Usage

import { getTag } from "utils/tag.ts";