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

@jbrew/dasher

v0.1.0

Published

Dasher text entry interface — zooming predictive text via arithmetic coding

Readme

Dasher

A text entry interface that turns cursor movement into text via arithmetic coding.

Dasher was created by the Inference Group at Cambridge, led by the late Sir David MacKay. You write by zooming into a fractal arrangement of characters or words, where each symbol's size reflects its probability given the preceding context. The result is part productivity software, part accessibility device, and part psychotropic cyborg fidget toy.

This is a JavaScript reimplementation supporting both character-level and word-level entry with pluggable language models.

Live demo

Quick Start

Vanilla JS

Serve the repo root and open the example in your browser:

cd dasher
python3 -m http.server 8000
# open http://localhost:8000/examples/vanilla/

Paste text, pick a mode (character or word), and click Load. Click the canvas to start, then move your mouse to write.

React

cd examples/react
npm install
npm run dev
# open http://localhost:5173/

See examples/react/App.jsx for the full source. The key API:

import { DasherCanvas, useDasher } from 'dasher/react';

const { modelRef, viewRef, modelReady, outputText } = useDasher({
  languageModel: ppm,
  mode: "character",
});

<DasherCanvas modelRef={modelRef} viewRef={viewRef}
  modelReady={modelReady} settings={{ mode: "character" }} />

Programmatic (no UI)

import { DasherModel, createPPMModel, ALPHABETS } from 'dasher';

const ppm = createPPMModel(ALPHABETS.LOWERCASE, { maxOrder: 5 });
ppm.train("the cat sat on the mat");

const model = new DasherModel();
model.setLanguageModel(ppm);
model.init();

// The model is now ready to receive cursor input via scheduleOneStep()

Language Models

Dasher works with any object implementing this interface:

interface LanguageModel {
  createContext(): Context;
  cloneContext(ctx: Context): Context;
  enterToken(ctx: Context, token: string): void;
  getContinuations(ctx: Context): Array<{
    token: string;
    prob: number;
    color?: number;
  }>;
}

Included Models

PPM (Prediction by Partial Matching) — Character-level model ported from the original Dasher C++ code. Trains on raw text and predicts the next character given a variable-length context. Best for the classic Dasher experience.

import { createPPMModel, ALPHABETS } from 'dasher';

const model = createPPMModel(ALPHABETS.LOWERCASE, {
  maxOrder: 5,   // Context length (default 5)
  alpha: 100,    // Escape probability (default 100)
  beta: 100,     // Count smoothing (default 100)
});
model.train(text);

Ngram — Word or character level model built from an in-memory transition matrix. Supports temperature for probability redistribution.

import { NgramLanguageModel, buildNgramIndex, tokenizers } from 'dasher';

// Word-level
const wordIndex = buildNgramIndex(text, 2);
const wordModel = new NgramLanguageModel(wordIndex, {
  maxContextSize: 2,
  temperature: 1.5,  // >1 flattens, <1 sharpens
});

// Character-level
const charIndex = buildNgramIndex(text, 5, { tokenize: tokenizers.character });
const charModel = new NgramLanguageModel(charIndex, { maxContextSize: 5 });

Custom Models

Implement the four-method interface above. For example, a uniform random model:

const uniformModel = {
  createContext: () => ({}),
  cloneContext: () => ({}),
  enterToken: () => {},
  getContinuations: () =>
    "abcdefghijklmnopqrstuvwxyz ".split("").map((c) => ({
      token: c,
      prob: 1 / 27,
    })),
};

Arithmetic Codec

Dasher sequences can be encoded as compact URL-safe strings:

import { encode, decode } from 'dasher';

const code = encode(['the', 'cat', 'sat'], wordModel);  // "ABcD.12"
const words = decode(code, wordModel);                   // ['the', 'cat', 'sat']

The encoding uses the language model's probability distribution, so likely sequences compress to shorter codes.

Architecture

src/
├── core/
│   ├── DasherModel.js      # Coordinate system, zoom dynamics, node tree
│   ├── DasherView.js       # Screen ↔ Dasher coordinate transforms
│   └── DasherRenderer.js   # Canvas rendering
├── models/
│   ├── PPMLanguageModel.js  # Character PPM (from original Dasher)
│   ├── NgramLanguageModel.js # Word/char ngram model
│   └── localNgrams.js       # Ngram index builder
├── codec/
│   └── arithmeticCodec.js   # Sequence ↔ compact string encoding
└── react/
    ├── DasherCanvas.jsx     # Canvas component with input handling
    └── useDasher.js         # Model lifecycle hook

Attribution

  • Original Dasher: David MacKay, David Ward, and the Inference Group at the University of Cambridge. dasher-project/dasher
  • PPM Language Model: JavaScript port of PPMLanguageModel.cpp by David Ward (1999-2005)
  • This implementation: Jamie Brew

License

MIT