# @echelon-framework/expression

Sandboxed expression evaluator for Echelon framework. Zero dependencies, safe evaluation.

Part of the **Echelon Framework** — Angular-based, config-driven dashboard & low-code platform.

## Installation

```bash
npm install @echelon-framework/expression
```

## Usage

```ts
import { evaluate, parse } from '@echelon-framework/expression';

// Simple expressions
evaluate('2 + 3'); // → 5
evaluate('price * quantity'); // → with context
evaluate('status === "active"'); // → boolean
evaluate('items.length > 0'); // → property access

// With context
const ctx = { price: 100, quantity: 5, status: 'active' };
evaluate('price * quantity', ctx); // → 500
evaluate('status === "active"', ctx); // → true

// Parse to AST (for validation/optimization)
const ast = parse('price > 100 && status === "active"');
```

## Supported operators

| Category        | Operators                          |
| --------------- | ---------------------------------- |
| Arithmetic      | `+`, `-`, `*`, `/`, `%`            |
| Comparison      | `===`, `!==`, `>`, `>=`, `<`, `<=` |
| Logical         | `&&`, `\|\|`, `!`                  |
| Property access | `.`, `?.`                          |
| Ternary         | `? :`                              |
| String          | `+` (concatenation)                |

## Security

- No `eval()`, no `Function()` constructor
- No access to global scope (window, document, process)
- Whitelist-based — only provided context variables accessible
- Safe for user-defined expressions in designer configs

## License

BUSL-1.1
