Back to browse
GitHub Repository

Tiny and CSP-safe expression language for JavaScript

1 starsJavaScript

Tiny and CSP-safe expression language for JavaScript

by robinvdvleuten·Jul 17, 2026·2 points·0 comments

AI Analysis

●●SolidCozyBig Brain

Tiny 1.2KB parser using precedence climbing instead of heavy math libraries.

Strengths
  • CSP-safe architecture eliminates eval risks by compiling to plain closures.
  • Strict equality operators prevent common JavaScript loose-coercion footguns.
  • Custom function registry allows extending logic without bloating the core.
Weaknesses
  • Lacks null-safe access operators and string concatenation found in larger libs.
  • No built-in caching means developers must implement memoization manually.
Target Audience

Frontend developers needing runtime logic evaluation

Similar To

expr-eval · mathjs · jsep

Post Description

For a feature on project I was working on, I needed a simple way to have some business logic like "expressions" evaluated at runtime. I only found a handfull packages either very old (e.g. expr-eval) or very Math oriented (e.g. Mathjs).

I wanted a way to have a very simple core "compile then evaluate" package that I could easily extend with custom functions needed for the project (so in theory I could support a full Math suite).

The result is this tiny `xprsn` package, and is somewhere around 1.2kb gzipped, extracted from the closed-source project. See https://github.com/robinvdvleuten/xprsn.

Not gonna lie here, as it is mostly Fable5 effort (you probably will notice by the terse, not very human-readable precedence climbing parser. But the point was to get a tiny working package, not some heavy brain exercise of myself :)

Despite some anti AI-slop people on HN, I wanted to share it here as I still think it would be useful to others.

Similar Projects