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

@hiperbrain/core

v0.4.0

Published

Hyperdimensional Computing (HDC / VSA) engine: bind, bundle, permute, cleanup memory, one-shot learning and analogical reasoning. Zero dependencies; runs in the browser, Node, Edge, Deno and Bun.

Readme

@hiperbrain/core

A tiny Hyperdimensional Computing (HDC / VSA) engine — the brain behind hiperbrain.com, as a zero-dependency library.

Teach it facts and it learns one-shot, answers by analogy, and degrades gracefully under noise — all with plain CPU math on typed arrays. No GPU, no training loop, no external API. The same input always produces the same vector, so results are deterministic and auditable.

Runs anywhere JavaScript runs: browser, Node, Edge, Deno, Bun.

npm install @hiperbrain/core

Quickstart

A collective knowledge brain

import { KnowledgeBrain } from "@hiperbrain/core";

const brain = new KnowledgeBrain();

brain.learn({ subject: "France", relation: "capital", object: "Paris" });
brain.learn({ subject: "Japan", relation: "capital", object: "Tokyo" });
brain.learn({ subject: "France", relation: "currency", object: "Euro" });
brain.learn({ subject: "Japan", relation: "currency", object: "Yen" });

brain.ask("France", "capital");        // → [{ name: "Paris", score: ... }, ...]
brain.askSubject("capital", "Tokyo");  // → [{ name: "Japan", ... }]

// "France is to Euro as Japan is to ___ ?"  (no rule tells it the relation)
brain.analogy("Euro", "France", "Japan");  // → [{ name: "Yen", ... }]
brain.recoverRelation("Euro", "France");   // → [{ name: "currency", ... }]  (explainable)
brain.similarConcepts("France");           // → nearest entities by holographic record

Calibrated confidence

import { recallConfidence } from "@hiperbrain/core";

const matches = brain.ask("France", "capital");
recallConfidence(matches); // → { score, confident, sigma }  (noise-sigma calibrated)

Typo-tolerant resolution

import { ConceptResolver } from "@hiperbrain/core";

const resolver = new ConceptResolver(["France", "Germany", "Japan"]);
resolver.resolve("Frnace")?.name; // → "France"

One-shot text classification

import { Brain } from "@hiperbrain/core";

const brain = new Brain();
brain.learnClass("en", ["the quick brown fox"]);
brain.learnClass("de", ["der schnelle braune fuchs"]);

brain.classify("a lazy dog");  // → [{ name: "en", score: ... }, ...]

Raw primitives

import { bind, bundle, permute, cosineSimilarity, seededHypervector } from "@hiperbrain/core";

const a = seededHypervector("apple");
const b = seededHypervector("red");
const bound = bind(a, b);                 // role/filler association (self-inverse)
cosineSimilarity(bind(bound, b), a);      // ≈ 1  — recover `a`

What's inside

| Export | What it does | | --- | --- | | bind, bundle, permute | The three core HDC operations | | cosineSimilarity, hammingDistance, corrupt | Compare and stress-test vectors | | seededHypervector, randomHypervector | Deterministic / random 10,000-d vectors | | packBits, unpackBits, bindPacked, similarityPacked | Bit-packed fast path (8x smaller; bind = XOR, similarity = popcount) | | ItemMemory | Cleanup memory (nearest atomic symbol), JSON-serializable | | LetterCodebook, encodeText | Character n-gram text encoder | | ConceptResolver | Typo-tolerant lookup of known names | | Brain | Records, analogy, classification, sequences, persistence | | KnowledgeBrain | Collective (subject, relation, object) memory with analogy, recoverRelation, similarConcepts | | recallConfidence | Noise-sigma calibrated confidence for any ranked result |

Why HDC?

  • One-shot learning — a fact is learned in a single superposition step.
  • Analogical reasoning — "the X of Y" falls straight out of vector algebra.
  • Fault tolerant — flip thousands of bits and recall still works.
  • Deterministic & explainable — same input → same vector, every time.
  • Tiny & portable — no dependencies, no GPU, runs at the edge.

Hosted API — reason over the live collective brain

Everything above runs fully offline and knows only what you teach it. To reason over the live collective brain — every fact the community has taught on hiperbrain.com — use the built-in HiperbrainClient. It wraps the hosted, credit-metered HTTP API, so every call requires an API key and spends credits server-side. A read (ask) costs 1 credit; a permanent, AI-verified write (teach) costs 10 and is refunded automatically if the fact does not land.

Mint a key by burning tokens for credits at hiperbrain.com/token.

import { HiperbrainClient } from "@hiperbrain/core";

const hb = new HiperbrainClient({ apiKey: "hb_live_..." }); // key is required

// Ask — 1 credit
const { answer, confidence, remaining } = await hb.ask("France", "capital");
//    → "Paris", { confident: true, ... }, 999

// Teach — 10 credits (refunded if it's a duplicate / rejected / lost a conflict)
await hb.teach({ subject: "Slovenia", relation: "capital", object: "Ljubljana" });

// Check the balance — free, spends nothing
await hb.balance(); // → 989

Out of credits or a bad key throws a typed HiperbrainApiError:

import { HiperbrainApiError } from "@hiperbrain/core";

try {
  await hb.ask("France", "capital");
} catch (e) {
  if (e instanceof HiperbrainApiError && e.outOfCredits) {
    // 402 — burn more tokens at /token to top up
  }
}

Self-hosting? Point the client at your own deployment with new HiperbrainClient({ apiKey, baseUrl: "https://your-host" }). On runtimes without a global fetch (Node < 18) pass one via the fetch option.

License

MIT