isData(reply: Reply): reply is DataReply
Checks if a reply is a data reply
Type guard function that narrows the Reply type to DataReply.
Use type guard to access data attributes
Use type guard to access data attributes
import { assertEquals } from "@std/assert"; import { parseReply, isData } from "@hertzg/routeros-api/protocol/reply"; const reply = parseReply(["!re", "=name=ether1"]); if (isData(reply)) { // TypeScript knows reply.attributes is defined here assertEquals(reply.attributes.name, "ether1"); }
reply: Reply
The reply to check
reply is DataReply
True if the reply is a DataReply