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

@backloghq/termlog

v0.1.2

Published

Log-structured full-text search index — segment-based posting lists with LSM compaction, BM25 ranking, zero native dependencies.

Readme

@backloghq/termlog

Log-structured full-text search index — segment-based posting lists with LSM compaction, BM25 ranking, zero native dependencies.

Install

npm install @backloghq/termlog

Usage

import { TermLog } from "@backloghq/termlog";

const index = await TermLog.open({ dir: "./my-index" });

await index.add("doc-1", "the quick brown fox");
await index.add("doc-2", "the lazy dog");
await index.flush();

const results = await index.search("fox", { limit: 10 });
// [{ docId: "doc-1", score: 0.655... }]  (BM25 — exact value depends on corpus)

await index.remove("doc-1");
await index.close();

Why

Existing FTS engines (Lucene, Tantivy) require native deps or a JVM. Most pure-JS alternatives serialize the index to a single in-memory blob — fine for small corpora, but they hit per-file size cliffs in the tens of thousands of documents. Termlog uses immutable on-disk segments with LSM compaction so the corpus scales without those ceilings.

Architecture

  • Posting liststerm → [docId, tf], compressed with VByte / delta encoding. (Positions reserved for a future release.)
  • Term dictionary — sorted on disk; binary search for lookup.
  • Segments — self-contained immutable files (term dict + postings). New writes create a new segment. Compaction merges N segments into 1.
  • Query execution — boolean (AND/OR) via posting iterators (zigzag merge for AND, union scan for OR), BM25 scoring on top.
  • Storage — abstracted via StorageBackend; local FS by default, S3 via @backloghq/termlog-s3.

S3 backend

S3 support is provided by the companion package @backloghq/termlog-s3:

npm install @backloghq/termlog @backloghq/termlog-s3
import { TermLog } from "@backloghq/termlog";
import { S3Backend } from "@backloghq/termlog-s3";
import { S3Client } from "@aws-sdk/client-s3";

const index = await TermLog.open({
  dir: "my-index",
  backend: new S3Backend({
    client: new S3Client({ region: "us-east-1" }),
    bucket: "my-bucket",
    prefix: "my-index/",
  }),
});

See the termlog-s3 README for IAM permissions, lifecycle rules, and MinIO/LocalStack usage.

Options

| Option | Default | Description | |---|---|---| | fanout | 4 | Same-tier segment count that triggers a merge (size-tiered LSM) | | flushThreshold | 1000 | Docs in write buffer before auto-flush | | k1 | 1.2 | BM25 term-saturation parameter | | b | 0.75 | BM25 length-normalization parameter |

Errors

| Class | When thrown | |---|---| | ManifestCorruptionError | manifest.json contains invalid JSON | | ManifestVersionError | manifest version is outside the supported range | | SegmentCorruptionError | CRC32 mismatch or missing segment file (.region tells you which) | | MappingCorruptionError | docids.snap or docids.log is corrupt | | TokenizerMismatchError | reopening an index with a different tokenizer config | | IndexLockedError | another process holds the advisory .lock file | | WriteStreamError | base class for streaming write failures (S3 multipart, etc.) |

Stats

| Method | Returns | Description | |---|---|---| | docCount() | number | Documents indexed across all flushed segments | | segmentCount() | number | Number of active on-disk segments | | estimatedBytes() | number | Approximate in-memory footprint (postings buffers + sidecar arrays + Maps); lower-bound estimate for memory-budget callers |

Multi-writer / S3 safety

Termlog is single-writer per index directory. On local FS an advisory .lock file prevents concurrent opens in the same process group. On S3 (or any shared storage) there is no distributed lock — you must ensure at most one writer per index path.

License

MIT