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

wwwbasic

v1.0.2

Published

An implementation of BASIC designed to be easy to run on the Web

Downloads

64

Readme

NPM Package

wwwBASIC

wwwBASIC is an implementation of BASIC (Beginner's All-purpose Symbolic Instruction Code) designed to be easy to run on the Web.

How to use wwwBASIC

You can include wwwBASIC directly in Web pages:

<!DOCTYPE html>
<html>
  <head>
    <script src="https://google.github.io/wwwbasic/wwwbasic.js"></script>
    <script type="text/basic">
      PRINT "Hello World!"
      FOR i = 1 to 10
        PRINT "Counting "; i
      NEXT i
    </script>
  </head>
</html>

You can also import wwwBASIC as a Node.js module.

Either install it via npm: npm install -S wwwbasic

or clone the repository: git clone https://github.com/google/wwwbasic.git

Then run your code:

var basic = require('wwwbasic'); // from NPM
// var basic = require('./wwwbasic.js'); // from within the cloned repository directory

// An ESM import is also available from wwwbasic.mjs
// import basic from "wwwbasic.mjs";

basic.Basic(
`
PRINT "Hello World!"
FOR i = 1 to 10
  PRINT "Counting "; i
NEXT i
`);

Features

It supports a range of features including:

  • Graphics: 24-bit color, PSET, LINE, CIRCLE.
  • Input: INKEY$, GETMOUSE.
  • Source is parsed and compiled to JavaScript at load time.

Examples

Options

While by default wwwBASIC processes script tags of type="text/basic", the interpreter can also be invoked with various options.

basic.Basic(codeText, {
  debug: true  // or false,
  bindings: {
    // a dictionary of external bindings, see below.
    name: myfunc,
  },
});

Default bindings are available from basic.ConsoleBindings(). Bindings for a canvas are available from basic.GraphicsBindings(canvas).

NOTE: External bindings are currently consindered a semi-unstable feature, use with caution.

A Bindings can be custom (see below), but a few are foundational:

  • PutCh(ch) - Print one character. PutCh(undefined) must flush.
  • Halt() - Print any final message at END.
  • TODO: Bindings for input!

Additionally, custom statements and procedures can be added with the following naming convention:

  • kind_name_arguments
  • kind = statement / call
  • name = the name of the subroutine or statement in lowercase
  • arguements = argument spec see below

The argument spec uses one character per argument:

  • i - input / I - optional input
  • o - output / O - optional output
  • p - point (x, y) / P - optional point (passes 2 values)
  • s - string flag / S - optional string flag (e.g. BF for LINE)
  • d - dash (e.g. in words like LINE)
  • v - varptr (e.g. in words list GET / PUT, passes buffer, offset)

EXAMPLE:

var bindings = GraphicsBindings(canvas);
bindings.statement_foo_pIS = function(x, y, color, style) {
  // x and y: are always available
  // color: might be undefined
  // style: might be undefined and is a literal string
};
basic.Basic(
`
foo (10, 20), 1, dashed
`, { bindings: mybindings });

Test Suite

wwwBASIC has a "work in progress" test suite. It can be run with: ./tests/run-tests.sh.

But Why?

The immediate trigger for wwwBASIC's existence was Ed Thelen's Nike Hercules simulator. It had been written in BASIC some time back, then ported to some unknown version of FreeBasic. However, while he had screenshots and source code, it also included a Windows .EXE to a download, and the statement, "guaranteed to be free of viruses" :-/

As it was meant to capture how something historical worked, it seemed unfortunate that something of this sort couldn't just be accessible directly on the web. Various whole system emulators that run on the web are available, but booting a whole system for a small program seemed like overkill.

Hence the first goal was to get this to run.

From there, bringing up DONKEY.BAS seemed a nice logical milestone. Bringing up GORILLA.BAS and NIBBLES.BAS are a current focus.

Source Code Headers

Every file containing source code must include copyright and license information. This includes any JS/CSS files that you might be serving out to browsers. (This is to help well-intentioned people avoid accidental copying that doesn't comply with the license.)

Apache header:

Copyright 2018 Google LLC

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    https://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.