{"id":26366,"library":"scheme2js","title":"scheme2js","description":"Version 1.4.2. A simple Scheme-to-JavaScript transpiler that converts Scheme expressions into JavaScript code. It supports basic Lisp constructs such as define, lambda, if, binary operations, and boolean expressions. The package includes a CLI tool (s2j) and a Node.js API. It features optional polyfill for pairs (cons, car, cdr). The library is lightweight and designed for educational purposes or small Scheme snippets. Release cadence is low, with no recent updates on GitHub.","status":"active","version":"1.4.2","language":"javascript","source_language":"en","source_url":"https://github.com/dongy7/scheme2js","tags":["javascript"],"install":[{"cmd":"npm install scheme2js","lang":"bash","label":"npm"},{"cmd":"yarn add scheme2js","lang":"bash","label":"yarn"},{"cmd":"pnpm add scheme2js","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"ESM default import; CJS require works but is not the recommended pattern for modern usage.","wrong":"const s2j = require('scheme2js')","symbol":"default","correct":"import s2j from 'scheme2js'"},{"note":"The module exports a single function as default; there is no named export.","wrong":"import { s2j } from 'scheme2js'","symbol":"default as named","correct":"import s2j from 'scheme2js'"},{"note":"The library does not ship TypeScript types; use its default export only.","wrong":"import { compile } from 'scheme2js'","symbol":"type definitions","correct":"import s2j from 'scheme2js'"}],"quickstart":{"code":"import s2j from 'scheme2js';\n\nconst schemeCode = `\n  (define (factorial n)\n    (if (eq n 0)\n        1\n        (* n (factorial (- n 1))))\n`;\n\nconst jsCode = s2j(schemeCode);\nconsole.log(jsCode);\n// Output:\n// function factorial(n) {\n//   return eq(n, 0) ? 1 : n * factorial(n - 1);\n// }","lang":"typescript","description":"Transpile a Scheme factorial function to JavaScript using the API."},"warnings":[{"fix":"Use only the documented constructs; refer to the README for supported features.","message":"The transpiler does not support all Scheme standards; it only handles a subset (define, lambda, if, binary ops, booleans). Complex macros or continuations will fail.","severity":"gotcha","affected_versions":"*"},{"fix":"Use the CLI without --pairs if you don't need pairs, or scope the polyfill manually.","message":"The `--pairs` flag adds a global polyfill for cons, car, cdr. This pollutes the global scope and may conflict with other libraries.","severity":"gotcha","affected_versions":"*"},{"fix":"Manually replace `var` with `let` or `const` after transpilation.","message":"The output uses `var` for definitions (e.g., `var foo = 1`). This may cause scoping issues in modern JavaScript contexts.","severity":"gotcha","affected_versions":"*"},{"fix":"Use ESM import syntax if your environment supports it.","message":"Require-style usage (const s2j = require('scheme2js')) is not deprecated but is not ESM-compatible. The package does not support ESM natively.","severity":"deprecated","affected_versions":"*"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Use `const s2j = require('scheme2js').default` or use ES module import.","cause":"The export might be a transpiled CommonJS module that does not export a default.","error":"const s2j = require('scheme2js') returns undefined"},{"fix":"Ensure the input is a string: `s2j(String(code))`.","cause":"The function expects a string argument; passing a Buffer or other type will throw.","error":"s2j(code) throws 'code is not a string'"},{"fix":"Ensure `--pairs` is used at compile time and the resulting JavaScript file includes the polyfill at the top.","cause":"The polyfill defines a helper `_` on the global object; if the code uses it before loading polyfill, references fail.","error":"_ is not defined (after using pairs polyfill)"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}