sesaparcours
    Preparing search index...
    interface MathNode {
        comment: string;
        isNode: true;
        isUpdateNode?: boolean;
        type: string;
        clone(): this;
        cloneDeep(): this;
        compile(): EvalFunction;
        equals(other: MathNode): boolean;
        evaluate(scope?: MathScope<any>): any;
        filter(
            callback: (node: MathNode, path: string, parent: MathNode) => any,
        ): MathNode[];
        forEach(
            callback: (node: MathNode, path: string, parent: MathNode) => void,
        ): void;
        map(
            callback: (node: MathNode, path: string, parent: MathNode) => MathNode,
        ): MathNode;
        toHTML(options?: object): string;
        toString(options?: object): string;
        toTex(options?: object): string;
        transform<TResult>(
            callback: (node: this, path: string, parent: MathNode) => TResult,
        ): TResult;
        traverse(
            callback: (node: MathNode, path: string, parent: MathNode) => void,
        ): void;
    }
    Index

    Properties

    comment: string
    isNode: true
    isUpdateNode?: boolean
    type: string

    Methods

    • Create a shallow clone of the node. The node itself is cloned, its childs are not cloned.

      Returns this

    • Create a deep clone of the node. Both the node as well as all its childs are cloned recursively.

      Returns this

    • Compile an expression into optimized JavaScript code. compile returns an object with a function evaluate([scope]) to evaluate. Example:

      Returns EvalFunction

    • Test whether this node equals an other node. Does a deep comparison of the values of both nodes.

      Parameters

      Returns boolean

    • Compile and eval an expression, this is the equivalent of doing node.compile().evaluate(scope). Example:

      Parameters

      Returns any

    • Filter nodes in an expression tree. The callback function is called as callback(node: MathNode, path: string, parent: MathNode) : boolean for every node in the tree, and must return a boolean. The function filter returns an array with nodes for which the test returned true. Parameter path is a string containing a relative JSON Path.

      Example:

      var node = math.parse('x^2 + x/4 + 3*y');
      var filtered = node.filter(function (node) {
      return node.isSymbolMathNode && node.name == 'x';
      });
      // returns an array with two entries: two SymbolMathNodes 'x'

      The callback function is called as callback(node: MathNode, path: string, parent: MathNode) : boolean for every node in the tree, and must return a boolean. The function filter returns an array with nodes for which the test returned true. Parameter path is a string containing a relative JSON Path.

      Parameters

      Returns MathNode[]

      Returns an array with nodes for which test returned true

    • [forEach description]

      Parameters

      Returns void

    • Transform a node. Creates a new MathNode having it’s child's be the results of calling the provided callback function for each of the child's of the original node. The callback function is called as callback(child: MathNode, path: string, parent: MathNode) and must return a MathNode. Parameter path is a string containing a relative JSON Path.

      See also transform, which is a recursive version of map.

      Parameters

      Returns MathNode

    • Get a HTML representation of the parsed expression.

      Parameters

      • Optionaloptions: object

      Returns string

    • Get a string representation of the parsed expression. This is not exactly the same as the original input.

      Parameters

      • Optionaloptions: object

      Returns string

    • Get a LaTeX representation of the expression.

      Parameters

      • Optionaloptions: object

      Returns string

    • Recursively transform an expression tree via a transform function. Similar to Array.map, but recursively executed on all nodes in the expression tree. The callback function is a mapping function accepting a node, and returning a replacement for the node or the original node. Function callback is called as callback(node: MathNode, path: string, parent: MathNode) for every node in the tree, and must return a MathNode. Parameter path is a string containing a relative JSON Path.

      For example, to replace all nodes of type SymbolMathNode having name ‘x’ with a ConstantMathNode with value 3:

      var node = math.parse('x^2 + 5*x');
      var transformed = node.transform(function (node, path, parent) {
      if (node.SymbolMathNode && node.name == 'x') {
      return new math.expression.node.ConstantMathNode(3);
      }
      else {
      return node;
      }
      });
      transformed.toString(); // returns '(3 ^ 2) + (5 * 3)'

      Type Parameters

      • TResult

      Parameters

      Returns TResult

    • traverse(callback)

      Recursively traverse all nodes in a node tree. Executes given callback for this node and each of its child nodes. Similar to Array.forEach, except recursive. The callback function is a mapping function accepting a node, and returning a replacement for the node or the original node. Function callback is called as callback(node: MathNode, path: string, parent: MathNode) for every node in the tree. Parameter path is a string containing a relative JSON Path. Example:

      var node = math.parse('3 * x + 2');
      node.traverse(function (node, path, parent) {
      switch (node.type) {
      case 'OperatorMathNode': console.log(node.type, node.op); break;
      case 'ConstantMathNode': console.log(node.type, node.value); break;
      case 'SymbolMathNode': console.log(node.type, node.name); break;
      default: console.log(node.type);
      }
      });
      // outputs:
      // OperatorMathNode +
      // OperatorMathNode *
      // ConstantMathNode 3
      // SymbolMathNode x
      // ConstantMathNode 2

      Parameters

      Returns void