BrainForge

raw JSON →
1.1.4 verified Fri May 01 auth: no javascript

BrainForge 1.1.4 is a JavaScript/TypeScript transpiler that converts code to an enhanced Brainfuck variant with advanced features like garbage collection, GUI/CLI support, and debugging. It maintains standard Brainfuck compatibility while adding optimizations. Ships TypeScript types. Released under MIT. Differentiator: extends the esoteric language for practical applications beyond simple code golf.

error Cannot find module 'brainforge' or its corresponding type declarations.
cause Missing TypeScript type definitions or incorrect installation
fix
Run 'npm install --save-dev @types/brainforge' if available, or ensure brainforge is installed as a dependency
error SyntaxError: Unexpected token 'export'
cause Using CommonJS require() on an ESM-only package
fix
Change to import syntax: import { transpile } from 'brainforge'
error TypeError: transpile is not a function
cause Incorrect import of default vs named export
fix
Use named import: import { transpile } from 'brainforge'
error Error: Node.js version must be >=16.0.0
cause Running on an older Node.js version
fix
Upgrade Node.js to version 16 or higher
breaking Removed support for Node.js <16
fix Upgrade Node.js to version 16 or higher
breaking Changed API: transpile now returns a Promise in v1.1.0+
fix Use await or .then() when calling transpile()
deprecated The 'compile' function is deprecated; use 'transpile' instead
fix Replace compile() with transpile()
gotcha TypeScript types are shipped but may be incomplete for advanced options
fix Use type assertions or augment types if needed
gotcha Generated Brainfuck code may exceed memory limits for large inputs
fix Set maxCellValue option to limit memory usage
gotcha ESM-only package; CommonJS require throws error
fix Use import syntax or switch to dynamic import()
npm install brainforge
yarn add brainforge
pnpm add brainforge

Shows how to transpile JavaScript to enhanced Brainfuck using the transpile function with optimization enabled.

import { transpile } from 'brainforge';

const jsCode = `
  let a = 10;
  let b = 20;
  console.log(a + b);
`;

try {
  const bfCode = transpile(jsCode, { optimize: true });
  console.log(bfCode);
} catch (err) {
  console.error('Transpilation failed:', err);
}