f7
f7 is a spreadsheet formula execution library
git clone https://git.vogt.world/f7.git
Log | Files | README.md | LICENSE.md
← All files
name: src/main/js/models/nodes/UnaryMinusOperationNode.ts
-rw-r--r--
719
 1import { Node } from "./Node";
 2import { NodeType } from "./NodeType";
 3
 4/**
 5 * Unary minus operation is the highest precedence operation, and is given a special node. While we could achieve this
 6 * by creating a formula-node that is functionally the same thing, I like the idea of 1) getting specific with out
 7 * node sub-classes, and 2) having something we can render as valid F7 code without mutating the user's input.
 8 */
 9export class UnaryMinusOperationNode extends Object implements Node {
10  readonly type: NodeType = NodeType.UnaryMinusOperation;
11  readonly operand: Node;
12
13  constructor(operand: Node) {
14    super();
15    this.operand = operand;
16  }
17
18  toString() {
19    return `-${this.operand.toString()}`;
20  }
21}