MCPcopy Create free account
hub / github.com/KaTeX/KaTeX / assertNodeType

Function assertNodeType

src/parseNode.ts:9–20  ·  view source on GitHub ↗
(
    node: AnyParseNode | null | undefined,
    type: NODETYPE,
)

Source from the content-addressed store, hash-verified

7 * typing. Throws if the node's type does not match.
8 */
9export function assertNodeType<NODETYPE extends NodeType>(
10 node: AnyParseNode | null | undefined,
11 type: NODETYPE,
12): ParseNode<NODETYPE> {
13 if (!node || node.type !== type) {
14 throw new Error(
15 `Expected node of type ${type}, but got ` +
16 (node ? `node of type ${node.type}` : String(node)));
17 }
18
19 return node as ParseNode<NODETYPE>;
20}
21
22/**
23 * Returns the node more strictly typed iff it is of the given type. Otherwise,

Callers 15

alignedHandlerFunction · 0.90
handlerFunction · 0.90
html.tsFile · 0.90
href.tsFile · 0.90
delimsizing.tsFile · 0.90
handlerFunction · 0.90
handlerFunction · 0.90
htmlBuilderFunction · 0.90
htmlBuilderFunction · 0.90
smash.tsFile · 0.90
htmlBuilderFunction · 0.90
handlerFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected