Registry / data / node.bf

node.bf

JSON →
library0.1.0jsnpmunverified

Node.bf is a JavaScript transpiler that compiles Node.js modules written in Brainfuck, an esoteric Turing-complete language using only characters +-<>[].,. Version 0.1.0 is the current stable release; the project appears to be in early development with no frequent updates. Unlike other Brainfuck interpreters or compilers, node.bf integrates with Node.js module system, allowing .bf files to be compiled into JavaScript modules that export a function. It uses Jison for parser generation and supports Webpack loaders for direct import of .bf files.

npm install node.bf
INSTALL
IMPORT
SIG · NODE.BF
N
node.bf
datajavascriptv0.1.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.

default import (compiled function)
✓ import myModule from './path/to/module.bf';
✗ const myModule = require('./path/to/module.bf');
Compiled .bf files export a default function. Direct require may not work without Webpack loader.
compile function (from node.bf package)
✓ import { compile } from 'node.bf';
✗ const compile = require('node.bf').compile;
ESM is preferred; CJS require works but check exports map.
run function (if exported)
✓ import { run } from 'node.bf';
✗ import { run } from 'node.bf/src';
run may be available; refer to docs for exact exports.

Shows how to compile a Brainfuck 'Hello World' program and use the resulting function with Node.js modules.

import { compile } from 'node.bf'; const fs = require('fs'); const path = require('path'); const bfSource = '++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---.+++++++..+++.>>.<-.<.+++.------.--------.>>+.>++.'; // Compile the Brainfuck source to a JavaScript function transpile(bfSource).then(jsCode => { // Create a Node module from the compiled code const modulePath = path.join(process.cwd(), 'hello.bf.js'); fs.writeFileSync(modulePath, `module.exports = function(input) { ${jsCode} };`); const helloWorld = require('./hello.bf.js'); console.log(helloWorld('')); }); function transpile(source) { return new Promise((resolve, reject) => { compile(source, (err, result) => { if (err) reject(err); else resolve(result); }); }); }
Debug
Known issues
gotchaThe compile function may require a callback; some versions might return a Promise.
fix
Check documentation for the exact API signature. Use a callback wrapper or check if .compile() returns a Promise.
affects: >=0.1.0
gotchaDirect require of .bf files without Webpack configuration will not work; you must either compile manually or use the custom loader.
fix
Either compile .bf files via API first or configure Webpack with node-bf loader.
affects: >=0.1.0
brokenMissing export 'run'? Some builds might not export 'run'.
fix
Use compile and create the module wrapper yourself, or check exports list.
affects: >=0.1.0
Errors
Common errors & fixes
Cannot find module 'node.bf'
Package not installed or incorrectly referenced.
fix
Run 'npm install node.bf' and ensure it's in package.json dependencies.
SyntaxError: Unexpected token >
Attempting to run .bf file directly with Node without compiling.
fix
Use node.bf compiler to transpile .bf file to .js before running.
TypeError: compile is not a function
Import/require syntax wrong or compile not exported.
fix
Use correct import: import { compile } from 'node.bf' or const compile = require('node.bf').compile.
Error: Input must be a string
Calling compiled function with non-string argument.
fix
Ensure the function receives a string input for the Brainfuck program's input tape.
Upgrade
Version history
0.1.0latest on npm
Audit
Dependencies
jisonrequiredparser generator used to build the lexer/parser from grammar
webpackoptionalused in development for bundling and custom loaders
Agent activity
4 hits · last 30 days
node
4
Resources
node.bf — npm install node.bf · libregistry