{"id":25797,"library":"js-to-lambda","title":"js-to-lambda","description":"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.","status":"abandoned","version":"0.4.0","language":"javascript","source_language":"en","source_url":null,"tags":["javascript","lambda","lambda calculus","turing machine","transpiler"],"install":[{"cmd":"npm install js-to-lambda","lang":"bash","label":"npm"},{"cmd":"yarn add js-to-lambda","lang":"bash","label":"yarn"},{"cmd":"pnpm add js-to-lambda","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Package does not export a CommonJS module; only ESM import works.","wrong":"const compile = require('js-to-lambda')","symbol":"compile","correct":"import { compile } from 'js-to-lambda'"},{"note":"Default export is named 'default'; named import 'compile' is the recommended entry point.","wrong":"const { default: jsToLambda } = require('js-to-lambda')","symbol":"default","correct":"import jsToLambda from 'js-to-lambda'"},{"note":"CJS destructuring works in Node environments that support ESM interop.","wrong":"","symbol":"compile","correct":"const { compile } = require('js-to-lambda')"}],"quickstart":{"code":"import { compile } from 'js-to-lambda';\n\n// Convert a simple function to lambda calculus\nconst code = `function f(a, b) { return a; }`;\nconst lambda = compile(code);\nconsole.log(lambda); // λa.λb.a\n\n// Curried function with multiple arguments\nconst code2 = `function add(x) { return function(y) { return x + y; } }`;\nconst lambda2 = compile(code2);\nconsole.log(lambda2); // λx.λy. (x + y)\n\n// Church encoding: boolean true\nconst trueCode = `function T(a, b) { return a; }`;\nconst trueLambda = compile(trueCode);\nconsole.log(trueLambda); // λa.λb.a\n\n// Church encoding: boolean false\nconst falseCode = `function F(a, b) { return b; }`;\nconst falseLambda = compile(falseCode);\nconsole.log(falseLambda); // λa.λb.b","lang":"javascript","description":"Demonstrates converting simple JavaScript functions to lambda calculus using the compile function. Shows Church encodings for true and false."},"warnings":[{"fix":"Check documentation for supported syntax; avoid using any constructs not explicitly listed as supported.","message":"The 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.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Rename inner parameter to avoid shadowing the outer scope.","message":"Shadowing 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.\"","severity":"breaking","affected_versions":">=0.1.0"},{"fix":"Consider forking the project or using an alternative approach if needed.","message":"The package has not been updated since 2018 and is effectively abandoned. No further development or bug fixes are expected.","severity":"deprecated","affected_versions":">=0.0.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Rename the inner parameter to a unique name.","cause":"Inner function parameter name shadows an outer function parameter.","error":"Variable 'a' at position X is already bound to a parent scope."},{"fix":"Rewrite the code using only supported constructs: function declarations, `function` keyword, basic arguments, and return statements.","cause":"Using unsupported JavaScript syntax (e.g., arrow functions, if statements, object literals).","error":"SyntaxError: Unexpected token"},{"fix":"Use `import { compile } from 'js-to-lambda'` or `const { compile } = require('js-to-lambda')` if using Node with CJS interop.","cause":"Incorrect import (CommonJS require instead of ESM import).","error":"TypeError: compile is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}