Registry / data / js-to-lambda

js-to-lambda

JSON →
library0.4.0jsnpmunverified

A transpiler that converts JavaScript code into lambda calculus expressions. Current version 0.4.0 is a WIP with limited functionality, supporting only function declarations, arguments, currying, and parsing functions as tokens. It converts JS functions to Church-encoded lambda terms but does not handle most JavaScript features (conditionals, loops, objects, etc.). Release cadence is irregular; the project is experimental and has not been updated since 2018. Differentiators: it's one of the few tools attempting JS-to-lambda conversion, but remains highly incomplete and is more a proof-of-concept than a production tool.

npm install js-to-lambda
INSTALL
IMPORT
SIG · JS-TO-LAMBDA
J
js-to-lambda
datajavascriptv0.4.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

compile
import { compile } from 'js-to-lambda'
const compile = require('js-to-lambda')
Package does not export a CommonJS module; only ESM import works.
default
import jsToLambda from 'js-to-lambda'
const { default: jsToLambda } = require('js-to-lambda')
Default export is named 'default'; named import 'compile' is the recommended entry point.
compile
const { compile } = require('js-to-lambda')
CJS destructuring works in Node environments that support ESM interop.

Demonstrates converting simple JavaScript functions to lambda calculus using the compile function. Shows Church encodings for true and false.

import { compile } from 'js-to-lambda'; // Convert a simple function to lambda calculus const code = `function f(a, b) { return a; }`; const lambda = compile(code); console.log(lambda); // λa.λb.a // Curried function with multiple arguments const code2 = `function add(x) { return function(y) { return x + y; } }`; const lambda2 = compile(code2); console.log(lambda2); // λx.λy. (x + y) // Church encoding: boolean true const trueCode = `function T(a, b) { return a; }`; const trueLambda = compile(trueCode); console.log(trueLambda); // λa.λb.a // Church encoding: boolean false const falseCode = `function F(a, b) { return b; }`; const falseLambda = compile(falseCode); console.log(falseLambda); // λa.λb.b
js-to-lambda --version
Debug
Known issues
gotchaThe package is a work-in-progress and severely incomplete. It only handles function declarations, basic currying, and function application. Most JavaScript constructs (if/else, loops, objects, arrays, arithmetic operations) are not supported and will cause errors or incorrect output.
fix
Check documentation for supported syntax; avoid using any constructs not explicitly listed as supported.
affects: >=0.0.0
breakingShadowing of variable names in nested functions throws an error. For example, `function f(a) { return function(a) { return a; } }` will throw: "Variable 'a' at position X is already bound to a parent scope."
fix
Rename inner parameter to avoid shadowing the outer scope.
affects: >=0.1.0
deprecatedThe package has not been updated since 2018 and is effectively abandoned. No further development or bug fixes are expected.
fix
Consider forking the project or using an alternative approach if needed.
affects: >=0.0.0
Errors
Common errors & fixes
Variable 'a' at position X is already bound to a parent scope.
Inner function parameter name shadows an outer function parameter.
fix
Rename the inner parameter to a unique name.
SyntaxError: Unexpected token
Using unsupported JavaScript syntax (e.g., arrow functions, if statements, object literals).
fix
Rewrite the code using only supported constructs: function declarations, `function` keyword, basic arguments, and return statements.
TypeError: compile is not a function
Incorrect import (CommonJS require instead of ESM import).
fix
Use `import { compile } from 'js-to-lambda'` or `const { compile } = require('js-to-lambda')` if using Node with CJS interop.
Upgrade
Version history
0.4.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
4 hits · last 30 days
node
4
Resources
js-to-lambda — npm install js-to-lambda · libregistry