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

lmc-interpreter

v1.0.4

Published

A barebones Little Man Computing instruction-set interpreter written in TypeScript.

Readme

lmc-interpreter

This is a simple interpreter/simulator for the Little Man Computing (LMC) architecture written in Typescript.

Components:

  • parser
  • interpreter

Installation

npm install lmc-interpreter
yarn add lmc-interpreter
pnpm add lmc-interpreter

Usage

import Interpreter from "./interpreter/Interpreter"; // or: Interpreter from "lmc-interpreter"
import Parser from "./parser/Parser"; // or: Parser from "lmc-interpreter"

// Parse a program
const parser = new Parser({
    program: `inp;out;add two;out;two dat 2`, // INP, OUT, ADD TWO, OUT, TWO DAT 2
    comments: {
        enabled: true,
        sequence: "//"
    },
    splitLines: {
        enabled: true,
        sequence: ";"
    }
});
const result = parser.parse();

// Interpret a program
// Note: the memory will not be reset upon .run() calls, so you may want to create a new Interpreter instance for each program
const interpreter = new Interpreter({
    program: result.instructions,
    events: {
        onInput: () => {
            const input = Math.floor(Math.random() * 9) + 1;
            console.log(`> Input: ${input}`);
            return input
        },
        onOutput: (value) => {
            console.log(`> Output: ${value}`);
        },
        onFinished: () => {
            console.log("> Finished!");
        }
        // onDump = dump per step
        // onLog = logs/actions
    },
    memorySize: 100
});
interpreter.run();

View example here.

Parser

Instructions

| Code | Instruction | Description | | ---- | ----------- | ----------- | | 0 | HLT | Stop/exit | | 1 | ADD | Adds the contents of the memory address provided to the Accumulator | | 2 | SUB | Subtracts the contents of the memory address provided from the Accumulator | | 3 | STA/STO | Stores the contents of the Accumulator in the memory address provided | | 4 | | Unused, throws an error | | 5 | LDA | Loads the contents of the memory address provided into the Accumulator | | 6 | BRA | Branches to the memory address provided | | 7 | BRZ | Branches to the memory address provided if the Accumulator is zero | | 8 | BRP | Branches to the memory address provided if the Accumulator is positive | | 9 | INP/OUT | Input (default 1)/Output (default 2), Codes | | 9 | OTC | Output Character, Codes |

All instructions are inherited from PeterHigginson.co.uk's Little Man Computing implementation.

I/O Codes

| Code | Description | | ---- | ----------- | | 1 | Input | | 2 | Output | | 22 | Output Character (OTC only, assigned by default) |

Syntax

The parser expects the following syntax for instructions:

<label?> <instruction> <operand?>

Using a space to split the tokens, this prevents labels from containing spaces as they will not be tokenised correctly. Read more here: Labels

Comments

The parser optionally supports comments using the # character. Comments can be placed at the end of a line or on a line by themselves.

Any content after the # character is ignored.

Split Lines

The parser optionally supports splitting lines using the ; character. This allows for multiple instructions to be placed on a single line.

Labels

Labels are optional and can be used to reference memory addresses.

Labels must fit the following syntax:

  • alphanumeric; tokensiation is based on spaces
  • can contain underscores
  • must not start with a number; to prevent confusion with memory addresses
  • must not match an instruction; to prevent confusion with instructions; <label> <opcode> v. <opcode> <operand> is identified by identifying the opcode position.

Interpreter

In comparison to Peter Higginson's implementation, this interpreter has the following fundamental differences:

  • unrestricted sizes (memory, accumulator, etc.)