Subscript is a modular and extensible expression parser and evaluator for JavaScript and TypeScript. It provides a lightweight core for building custom Domain Specific Languages (DSLs) and offers several ready-to-use presets, including `subscript` (common expressions), `justin` (JSON, templates, arrow functions, optional chaining), and `jessie` (a JavaScript subset supporting statements, functions, and control flow). The package is currently at version 10.3.2 and maintains an active release cadence with frequent minor and major updates introducing new syntax features, performance improvements, and API refinements. Key differentiators include its small bundle size (~2KB core), high performance for both parsing and evaluation, a minimal JSON-compatible Abstract Syntax Tree (AST), and built-in sandboxing to prevent prototype pollution and global access. It is designed to be universal, fast, and safe, making it suitable for templates, calculators, safe evaluation environments, and language subsets.
No compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
The main `subscript` preset is the default export. All versions >=10.0.0 are ESM-only.
The `justin` preset is a named export from a specific module path, requiring the `.js` extension in ESM environments.
The `parse` function, along with `compile`, `binary`, `operator`, etc., are named exports from the main package entry point.
The AST codegeneration utility is `codegen`, not `stringify`, and is located in a specific utility path.
Demonstrates parsing and evaluating a Jessie preset expression with functions and control flow, showcasing sandboxed execution and context passing.
Breaking-change detection hasn't run for this library yet.
CVE tracking and dependency tree are planned for a later release.
No traffic data recorded yet.