
ExpresZo Typescript¶
A fast, safe, and extensible expression evaluator for JavaScript and TypeScript.
ExpresZo parses and evaluates expressions at runtime — a configurable alternative to eval() that won't execute arbitrary code. Use it to power user-facing formula editors, rule engines, template systems, or any place you need to evaluate dynamic expressions safely.
Why ExpresZo?¶
Fast¶
ExpresZo uses a Pratt parser — a top-down operator-precedence parsing algorithm that processes tokens in a single pass with no backtracking. Compared to the recursive-descent parser in the original expr-eval, this means significantly faster parsing, predictable linear performance scaling, and better error messages with precise diagnostics.
Parsed expressions compile to an immutable AST that can be evaluated repeatedly against different variable sets with near-zero overhead.
Safe¶
- No code execution — expressions can only call explicitly registered functions
- Prototype pollution protection — access to
__proto__,prototype, andconstructoris blocked - Recursion depth limit — deeply nested expressions are rejected at parse time
- No
eval()ornew Function()— evaluation runs on a stack-based AST walker
Extensible¶
Build exactly the parser you need with tree-shakeable presets, or use the full kitchen-sink parser with zero configuration.
Installation¶
Quick Start¶
import { Parser } from '@pro-fa/expreszo';
const parser = new Parser();
const expr = parser.parse('2 * x + 1');
console.log(expr.evaluate({ x: 3 })); // 7
Documentation¶
For Expression Writers¶
- Quick Reference - Cheat sheet of operators, functions, and syntax
- Expression Syntax - Complete syntax reference with examples
For Developers¶
- Parser - Parser configuration, methods, and customization
- Expression - Expression object methods: evaluate, simplify, variables
- Advanced Features - Promises, custom resolution, type conversion, operator customization
- Language Service - IDE integration: completions, hover info, diagnostics, Monaco Editor
- MCP Server - Expose the language service to AI assistants (Claude Desktop, Claude Code, Cursor)
- Migration Guide - Migrating from expr-eval, legacy mode, version history
For Contributors¶
- Contributing - Development setup, code style, and PR guidelines
- Performance Testing - Benchmarks, profiling, and optimization guidance
- Breaking Changes - Version-by-version breaking change documentation
Playground¶
Try it live at the Playground — an interactive environment with code completions, syntax highlighting, and real-time evaluation.
License¶
See LICENSE.txt for license information.