npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@jurian.w/bf-js

v1.2.2

Published

A Brainfuck transpiler and interpreter written in JavaScript.

Readme

brainfuck-js

This Project let you run brainfuck code in Javascript

Installation

Use npm to install the package

npm i @jurian.w/bf-js

Usage

Transpiler

The transpiler can be used to run brainfuck code efficiently in Javascript. It transpiles the brainfuck code to a Javascript function, which can be run multiple times with different input.

Import and create transpiler instance

const Transpiler = require("@jurian.w/bf-js/transpiler");
const transpiler = new Transpiler();

Transpile

You can transpile brainfuck code to a Javascript function using the transpile() method. It needs your brainfuck code as a string as argument.

const code = ",.+."; // Brainfuck code
const success = transpiler.transpile(code); // returns true if transpilation was successful

Run

After transpiling, you can run the transpiled code using the run() method. It needs a string as argument that is a sequence of all input values. It returns the output as a string. If there is a critical error, it returns false. Critical errors are:

  • No code has been transpiled yet
  • No input string has been provided
  • Ran into an infinite loop (see LoopLimit for more information)
const result = transpiler.run("ABC"); 

LoopLimit

To prevent infinite loops, there is a loop limit. The default is 2000 iterations per loop. You can change this limit by setting the loopLimit() property of the transpiler instance. It will change the limit for all future runs. It needs a positive integer as argument.

const success = transpiler.setLoopLimit(250); // returns true if the limit was set successfully

Interpreter

The interpreter can be used to translate brainfuck code while running it. It is less efficient than the transpiler, but is better for debugging.

Import and create interpreter instance

const Interpreter = require("@jurian.w/bf-js/interpreter");

const interpreter = new Interpreter();

Build

Before running, the interpreter needs to build the script structure. You can do this using the build() method. It needs your brainfuck code as a string as argument. The first argument is the brainfuck code. With the optional second argument you can enable console feedback by setting it to true. The function returns true if the build was successful, otherwise it returns false.

const code = ',.+.>+++[->+++[-]<]<';
const success = interpreter.build(code);

Structure

You can get the structure of the built code using the getStructure() method. It shows the structure of the code in the console. Optionally you can provide true as an argument to get console feedback while building the structure.

const success = interpreter.getStructure();

Output example:

Script structure:
1 | ,
2 | .
3 | +
4 | .
5 | >
6 | +
7 | +
8 | +
9 | Loop:
   1| -
   2| >
   3| +
   4| +
   5| +
   6| Loop:
      1| -
   7| <
10| <
End of script structure.

LoopLimit

To prevent infinite loops, there is a loop limit. The default is 2000 iterations per loop. You can change this limit by setting the loopLimit() property of the interpreter instance. It will change the limit for all future runs. It needs a positive integer as first argument. Optionally you can provide true as a second argument to get console feedback while setting the limit.

const success = interpreter.setLoopLimit(250);

Execute

After building the structure, you can run the code using the execute() method. It needs a string as argument that is a sequence of all input values. Optionally you can provide true as a second argument to get console feedback while executing the code. It returns the output as a string. If there is a critical error, the command that caused the error will be skipped and the execution will continue.

const response = interpreter.execute("ABC");

Execute with feedback log

You can also get a feedback log while executing the code. It needs the same arguments as the execute() method. It returns an object with three properties:

  • error: A boolean that indicates if a critical error occurred
  • result: The output as a string
  • responses: An array with objects that contains char (the output character) and int (the ASCII value of the output character)
const response = interpreter.executeAndShowFullLog("ABC");

Example output:

------------------------------------------------
Code progress:
↓
,+.,+.
Next input character:
↓
ABC
Insert input value: "A" → 65
 ↓ Selected
[0]
 ↓ Set to 65
[65]

 Current output:
"" 
------------------------------------------------
Code progress:
 ↓
,+.,+.
Next input character:
 ↓
ABC
Increase Storage value
 ↓ Selected
[65]
 ↓ Added 1
[66]

 Current output:
"" 
------------------------------------------------
Code progress:
  ↓
,+.,+.
Next input character:
 ↓
ABC
Select current char to output: "B" with code 66
 ↓ Selected
[66]
 ↓ Get current value
[66]

 Current output:
"" ← "B" Ascii 66
------------------------------------------------
Code progress:
   ↓
,+.,+.
Next input character:
 ↓
ABC
Insert input value: "B" → 66
 ↓ Selected
[66]
 ↓ Set to 66
[66]

 Current output:
"B" 
------------------------------------------------
Code progress:
    ↓
,+.,+.
Next input character:
  ↓
ABC
Increase Storage value
 ↓ Selected
[66]
 ↓ Added 1
[67]

 Current output:
"B" 
------------------------------------------------
Code progress:
     ↓
,+.,+.
Next input character:
  ↓
ABC
Select current char to output: "C" with code 67
 ↓ Selected
[67]
 ↓ Get current value
[67]

 Current output:
"B" ← "C" Ascii 67
------------------------------------------------
RAM Usage:
rss          39.34 MB
heapTotal    5.09 MB
heapUsed     4.26 MB
external     1.48 MB
arrayBuffers 0.01 MB

Execution completed successfully.
Final output: "BC"

Execute and replay step by step

You can also run the code, and replay it step by step. It needs the same arguments as the execute() method. If there is a critical error, the command that caused the error will be skipped and the execution will continue. It returns an object with three properties:

  • error: A boolean that indicates if a critical error occurred
  • result: The output as a string
  • responses: An array with objects that contains char (the output character) and int (the ASCII value of the output character)

Important ! : This function is asynchronous, so you need to use await or .then() to handle it correctly.

const response = await interpreter.executeAndShowStepByStepRePlay("ABC");

Example output:

RAM Usage:
rss          37.58 MB
heapTotal    4.84 MB
heapUsed     3.53 MB
external     1.20 MB
arrayBuffers 0.01 MB
------------------------------------------------
Code progress:  
↓              
,+.,+.        
Next input character:
↓           
ABC        
Insert input value: "A" → 65
 ↓ Selected
[0]     
 ↓ Set to 65
[65]  
     
 Current output:
"" 
------------------------------------------------
Press enter to show next step