ActiveUI

ActiveUI

  • User Guide
  • Developer Documentation

Home > @activeviam/activeui-sdk > NodeMatcherFactory

NodeMatcherFactory type

Provides a fluent API to match nodes in a parsed statement.

Signature:

export declare type NodeMatcherFactory = (a: MdxNode) => NodeMatcher;

Remarks

Pass an MdxNode to this function to create a NodeMatcher that lets you write tests for the node and its children.

At the end of the chain, call .matches() to get a boolean result. If you need more information about the match success or failure, call .matchDetails() on the NodeMatcher.

Example 1

const nodeMatcher = activeUI.mdx.nodeMatcher(node); const nodeIsAComparingFilterFunction = nodeMatcher .isFunction("Filter") .hasNArguments(2) .subArg(1, conditionMatcher => conditionMatcher.isFunction("<", ">", "<=", ">=").hasNArguments(2) ) .matches();

Example 2

const isStringOrNullMatcher = activeUI.mdx.nodeMatcher(node).isString().or().isNull(); if (isStringOrNullMatcher.matches()) { console.log(node, 'is a string or is NULL'); } else { throw new Error('please pass a valid MdxNode'); }

  • NodeMatcherFactory type
  • Remarks
  • Example 1
  • Example 2
Copyright © 2019 ActiveViam