Skip to main content

A Brainfuck interpreter for JavaScript/TypeScript environment.

Works with
It is unknown whether this package works with Bun
It is unknown whether this package works with Cloudflare Workers
This package works with Node.js
This package works with Deno
This package works with Browsers
JSR Score
100%
Published
a month ago (0.2.0)

jsr:@takejohn/brainfuck

A Brainfuck interpreter for JavaScript/TypeScript environment.

Installation

  • Deno:
    deno add @takejohn/brainfuck
    
  • npm:
    npx jsr add @takejohn/brainfuck
    
  • Yarn:
    yarn dlx jsr add @takejohn/brainfuck
    
  • pnpm:
    pnpm dlx jsr add @takejohn/brainfuck
    
  • Bun:
    bunx jsr add @takejohn/brainfuck
    

Example

import { Interpreter } from '@takejohn/brainfuck';

const interpreter = new Interpreter();
const program = `
++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---.+++++++..+++.>>.<-.<.+++.------.--------.>>+.>++.
`;
const execution = interpreter.execute(program);

let output = '';
while (true) {
    const value = await Promise.race([interpreter.output(), execution]);
    if (value == null) { // When execution is done
        break;
    }
    output += String.fromCharCode(value);
}
console.log(output); // 'Hello World!\n"
Built and signed on
GitHub Actions
View transparency log

Add Package

deno add @takejohn/brainfuck

Import symbol

import * as mod from "@takejohn/brainfuck";

Add Package

npx jsr add @takejohn/brainfuck

Import symbol

import * as mod from "@takejohn/brainfuck";

Add Package

yarn dlx jsr add @takejohn/brainfuck

Import symbol

import * as mod from "@takejohn/brainfuck";

Add Package

pnpm dlx jsr add @takejohn/brainfuck

Import symbol

import * as mod from "@takejohn/brainfuck";

Add Package

bunx jsr add @takejohn/brainfuck

Import symbol

import * as mod from "@takejohn/brainfuck";