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

syrupdotts

v0.1.0

Published

A variable n-gram powered search engine for intelligent completion and semantic search

Readme

🍯 Syrup.ts

A high-performance, variable n-gram search engine library for TypeScript and JavaScript. Syrup enables developers to build context-aware autocomplete, semantic completions, and multi-document search with minimal overhead.

✨ Key Features

  • Variable N-gram Indexing – Deep-index text to provide multi-token, context-sensitive suggestions.
  • Blazing Fast – Optimized in-memory architecture for sub-millisecond retrieval.
  • Document Management – Organize data into discrete documents for scoped querying and easy cleanup.
  • Reference Mapping – Attach metadata or IDs to indexed content for rich search results.
  • Fully Type-Safe – Written in TypeScript with comprehensive interface definitions.

Demo + Docs

Coming Soon: A more rudamentary version of syrup is already used on my personal portfolio justinwhite.work for search suggestions

🚀 Installation

npm install syrup-search

Quick Start

import { SyrupCore } from 'syrup-search';

// Initialize with custom depth
const engine = new SyrupCore({
    caseSensitive: false,
    maxDepth: 3
});

// "Infuse" the engine with content
engine.infuse("the quick brown fox jumps");

// Predict the next tokens
const { completions } = engine.predict({ query: "the quick" });

console.log(completions); 
// Output: ["brown", "brown fox", "brown fox jumps"]

🛠 Usage Patterns

Document-Scoped Search Manage specific sets of data using SyrupDocumentHandle.

// Create a managed document
const doc = engine.document("user_manual_01", "To restart the device, hold the power button.");

// Add more content to the same document later
doc.infuse("Ensure the power cable is plugged in.");

// Query results will now include document IDs
const results = engine.predict({ query: "power" });
console.log(results.documents); // ["user_manual_01"]

// Remove document and its associated indices
doc.delete();

Metadata & References

Link external IDs or objects to your chains

engine.infuse("API documentation", ["link_01", "tag_docs"]);

const results = engine.predict({ query: "API" });
console.log(results.references); // ["link_01", "tag_docs"]

🧠 How it works

  1. Tokenization: Splits input into units (e.g., ["hello", "world"]).
  2. Permutation: Generates n-grams from length 1 up to maxDepth.
  3. Mapping: Each n-gram acts as a key to an array of future token sequences.

Example: "hello world how are you" (maxDepth: 3)

  • Key: "hello" -> Val: ["world"], ["world how"], ["world how are"]
  • Key: "hello world" -> Val: ["how"], ["how are"], ["how are you"]

📊 Performance & Complexity

n = total tokens, d = maxDepth

  • Indexing Time: O(n * d^2) (Creating grams and updating internal pointers)

  • Search Time: O(1) (Average case via Hash Map lookup)

  • Space: O(n * d) (Total index entries stored in memory)

🧑‍💻 API Summary

SyrupCoreHandle The main API you interact with unless your querying a specific document

.infuse(content: string, refs?: string[])    // Index text globally
.predict(options: SyrupQueryOptions)         // Query completions/docs
.document(id: string, content: string)       // Create/manage a document
.use(id:string)                              // Access an existing document
.deleteDocument(id: string)                  // Wipe document from index
.getDocumentIds()                            // List all active doc IDs

SyrupDocumentHandle The scoped API used by documents (you can get this with .document() or .use())

.infuse(content: string, refs?: string[])    // Add content to this doc
.predict(options: SyrupQueryOptions)         // Query only this doc's scope
.delete()                                    // Self-destruct document data