github RecoLabs/gnata v0.5.1

3 hours ago

Changes

Features

  • TinyGo / WASI support. gnata builds and runs identically under TinyGo for wasip1, including -scheduler=none. The full jsonata-js conformance suite passes with no differences from native. See the TinyGo section in the README and the new examples/wasi. (#33)
  • and / or / $not fast path. Compositions of fast-eligible leaves are now answered on the byte fast path instead of decoding the document, exposed as Expression.IsBooleanFastPath(). Batches with these conditions are up to 99% faster. (#32)
  • WithReadOnlyCustomFuncArgs() (opt-in StreamEvaluator option): custom functions share a cached map[string]any view of evaluator-decoded input objects instead of a fresh copy per call. Default behaviour is unchanged. (#33)

Performance (#33)

  • Native geomean −7.0% time, −8.9% allocations; EvalBytes on complex expressions −37% to −40%; StreamEvaluator −27%.
  • WASM (Go wasip1) −7.8%; TinyGo is about 1.9× faster than Go wasip1 with a binary about 5× smaller.
  • Single-pass DecodeJSON, single-buffer JSON encoding, allocation-free plan-cache lookup and an inlined per-node cancellation check. Eval on pre-parsed data allocates exactly as before.

Fixes

  • Path-vs-literal = / != comparisons whose walked path ends on a one-element array returned the opposite result on the byte fast path (regression since v0.4.0). (#32)
  • StreamEvaluator bypassed a custom function registered under a fast-path builtin name (e.g. $exists). (#32)
  • Range operator: huge bounds no longer wrap or loop forever ([1e20..1e20] previously exhausted memory). (#33)
  • Numeric arguments are clamped instead of overflowing on conversion to int (indexes, $substring, $round, $pad, $split / $match / $replace limits, $formatBase, $flatten). (#33)
  • Decoded strings and the regex cache no longer retain references to caller buffers. (#33)

Behaviour changes (#33)

  • Out-of-range numeric arguments (≥ 2⁶³ or ≤ −2⁶³) to $substring, $split, $match and $replace now behave as "unbounded", like jsonata-js.

  • Infinite range bounds return T2003 / T2004.

  • WithTimeout is enforced at function-call granularity without a timer goroutine; a single builtin or custom-function call isn't interrupted.

  • Invalid UTF-8 in strings encodes as a raw U+FFFD on every toolchain (as Go 1.25+'s default encoding/json does).

  • Custom functions: arrays of scalars are passed through uncopied and must not be modified (maps are still copied per call).

  • npm: gnata-js@0.5.1

Don't miss a new gnata release

NewReleases is sending notifications on new releases.