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

retrobasic-wasm

v0.1.4

Published

Run classic BASIC programs in Node.js and the browser, powered by a WebAssembly build of the RetroBASIC interpreter.

Downloads

197

Readme

retrobasic-wasm

npm license: GPL-2.0-only play demo

Run classic BASIC programs wherever JavaScript runs. retrobasic-wasm packages the RetroBASIC interpreter as a zero-dependency, single-file WebAssembly bundle. Perfect for preserving vintage BASIC software and running retro text games like The Oregon Trail, Hammurabi, Lunar Lander, and Super Star Trek directly in Node.js or modern browsers.

Install

npm install retrobasic-wasm

Requires Node.js 18 or later. This is an ESM-only package; use import, not require().

Usage

Node.js

import { runBasic } from "retrobasic-wasm";

const exitCode = await runBasic({
  source: `
    10 PRINT "Hello from WASM!"
    20 END
  `,
  onStdout: (line) => console.log(line),
});

Browser

import { runBasic } from "retrobasic-wasm";

const response = await fetch("/program.bas");
const source = await response.text();

const outputElement = document.getElementById("terminal");

await runBasic({
  source,
  onStdout: (line) => {
    if (outputElement) outputElement.textContent += line + "\n";
  },
});

Interactive input

Programs that use INPUT can receive user input via the stdin option. Each entry is one input line; a trailing newline is added when needed.

import { runBasic } from "retrobasic-wasm";

const exitCode = await runBasic({
  source: `
    10 INPUT "What is your name? "; N$
    20 PRINT "Hello, "; N$; "!"
    30 END
  `,
  stdin: ["Alice"],
  onStdout: (line) => console.log(line),
});

API

runBasic(options: RunBasicOptions): Promise<number>

Runs a BASIC program via WebAssembly.

| Option | Type | Description | | ---------- | ------------------------ | ------------------------------------------------------ | | source | string | The BASIC program source code | | onStdout | (line: string) => void | Called for each line of standard output | | onStderr | (line: string) => void | Called for each line of standard error | | stdin | readonly string[] | Input lines fed to INPUT statements, one per element |

stdin also accepts a readonly array, so a frozen array or TypeScript tuple is valid. runBasic creates a fresh interpreter for every call, making concurrent calls isolated.

Returns the interpreter exit code — 0 typically indicates success; non-zero indicates an interpreter error or STOP. Errors while loading or initializing the WebAssembly module reject the promise.

onStdout and onStderr receive one newline-free line at a time. Render a newline yourself when writing those values to a terminal or DOM element.

Types

type BasicOutputHandler = (line: string) => void;

interface RunBasicOptions {
  source: string;
  stdin?: readonly string[];
  onStdout?: BasicOutputHandler;
  onStderr?: BasicOutputHandler;
}

The package exports runBasic, RunBasicOptions, and BasicOutputHandler.

Compatibility

RetroBASIC implements its own BASIC dialect. Program compatibility depends on the statements and extensions a program uses; this package exposes the interpreter rather than translating BASIC to JavaScript.

Demo

The repository includes an interactive browser demo running The Oregon Trail, Hammurabi, Lunar Lander, and Super Star Trek.

Development

Building the WASM binary requires Emscripten, Bison, and Flex.

# From the repository root
npm install

# Build the WASM binary, then re-bundle dist/ against it
npm run build:wasm
npm run build

# Start the Vite dev server (demo)
npm run dev

# Run format, lint, and test
npm run all

License

This package is licensed under GPL-2.0-only. It includes a modified WebAssembly build of RetroBASIC; copyright and complete-source information are in NOTICE. The corresponding source and build scripts are available in the Basicade repository.