LambdaJSON-js
raw JSON → 1.1.8 verified Fri May 01 auth: no javascript
A compiler that translates LambdaJSON — a pure functional programming language represented in JSON — into executable JavaScript functions. Current stable version is 1.1.8. The library is designed for embedding functional logic defined entirely in JSON, with no external dependencies and a small footprint. Key differentiators: no runtime, compiles to plain JS; pure functional semantics; good for dynamic expression evaluation in JSON-based systems. Release cadence is irregular.
Common errors
error SyntaxError: import { compile } from 'lambdajson-js'; ↓
cause Running in a CommonJS module (require not supported).
fix
Change to 'type': 'module' in package.json or use dynamic import().
error TypeError: compile is not a function ↓
cause Importing default instead of named export compile.
fix
Use import { compile } from 'lambdajson-js' (named import).
error Error: ReferenceError: x is not defined ↓
cause Referencing undefined variable in LambdaJSON program.
fix
Ensure all variables used in the program are defined in the scope or passed as arguments.
Warnings
breaking LambdaJSON-js is ESM-only; requires Node >= 12.22 or modern browser. ↓
fix Ensure project is ESM (type: 'module' in package.json) or use dynamic import.
breaking The compile function throws if the LambdaJSON program contains undefined variables. ↓
fix Wrap compile in try/catch or validate program structure beforehand.
gotcha Functions compiled with compile are closures capturing the original program; avoid sharing compiled functions across different program versions. ↓
fix Create a new compiled function for each program.
deprecated The old 'run' function (directly executes LambdaJSON) was removed in v1.1.0. ↓
fix Use compile() to get a function, then call it.
Install
npm install lambdajson-js yarn add lambdajson-js pnpm add lambdajson-js Imports
- compile wrong
const compile = require('lambdajson-js')correctimport { compile } from 'lambdajson-js' - evalProgram wrong
import evalProgram from 'lambdajson-js'correctimport { evalProgram } from 'lambdajson-js' - VERSION wrong
const VERSION = require('lambdajson-js').VERSIONcorrectimport { VERSION } from 'lambdajson-js'
Quickstart
import { compile } from 'lambdajson-js';
const program = {
$sum: ['#', 2]
};
const f = compile(program);
console.log(f(1)); // => 3