Skip to content

Releases: bitcode-framework/expr-js

v1.17.8

10 Jun 18:36

Choose a tag to compare

TypeScript port of expr-lang/expr v1.17.8.

Highlights

  • Dual output: ESM + CJS + type declarations
  • 60+ builtin functions — len, max, min, sum, type, keys, values, sort, string/math/date helpers
  • Full language surface — arithmetic, comparison, logical, bitwise operators
  • Ternary ? : and if {} else {} conditionals
  • let declarations, sequences (;), member access, optional chaining (?.), slicing, ranges (1..5)
  • Pipes (|), nil-coalescing (??)
  • Predicates — all, any, none, one, filter, map, count, find, findIndex, findLast, findLastIndex, groupBy, sortBy, reduce
  • Compile-time type checker via Env()
  • Optimizer — constant folding, predicate fusion, in_array, in_range, sum/map optimizations
  • AST patchers, custom functions, operator overloading
  • Zero runtime dependencies
  • Parity testing infrastructure with Go fixture generator

Numeric Model

Go semantics preserved in TypeScript:

  • Go int/int64 → JS bigint
  • Go float64 → JS number

Install

npm install @bitcode-framework/expr-js

Usage

import { Compile, Run, Eval } from '@bitcode-framework/expr-js';

Eval('1 + 2', null);                        // => 3n
Eval('user.age >= 18', { user: { age: 21 } }); // => true

const program = Compile('price * qty');
Run(program, { price: 10n, qty: 3n });     // => 30n