MCPcopy
hub / github.com/KaTeX/KaTeX / assertNodeType

Function assertNodeType

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

Source from the content-addressed store, hash-verified

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

Used in the wild real call sites across dependent graphs

searching dependent graphs…