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

@kurajs/search

v0.1.0

Published

Kura — retrieval engine: BM25 keyword search (+ hybrid fusion), portable and zero-dependency. Pairs with @kurajs/core's vector search.

Downloads

3,528

Readme

@kurajs/search

Portable, zero-dependency retrieval primitives for Kura: BM25 keyword search, Reciprocal Rank Fusion (to blend keyword + semantic), and a pluggable, per-locale tokenizer layer. Runs identically on Node, Bun, Deno, Cloudflare Workers, and the browser.

BM25

import { Bm25 } from "@kurajs/search";

const bm = Bm25.from([
  { id: "a", text: "vector search engine", data: { url: "/a" } },
  { id: "b", text: "database indexing and query planning", data: { url: "/b" } },
]);

bm.search("search", { topK: 5 }); // → [{ id, score, data }, ...]

Hybrid (RRF)

rrf / rrfScored fuse several ranked lists by rank, so a BM25 score and a cosine similarity don't need to be comparable:

import { rrfScored } from "@kurajs/search";

const fused = rrfScored(
  [{ hits: keywordHits }, { hits: semanticHits }],
  (h) => h.slug,
  { topK: 8 },
); // → [{ item, score }, ...] in fused order

Per-locale tokenizers

Bm25 accepts a single tokenize function or a resolveTokenizer that picks one by language, so one index can tokenize each document by its own locale (and each query by the query locale). byLocale() builds the resolver (case-insensitive, with primary-subtag fallback). CJK tokenizers live in @kurajs/tokenizers:

import { Bm25, byLocale, latinTokenizer } from "@kurajs/search";
import { cjkSegmenter } from "@kurajs/tokenizers";

const bm = Bm25.from(records, {
  resolveTokenizer: byLocale({
    default: latinTokenizer,
    zh: cjkSegmenter("zh"),
    ja: cjkSegmenter("ja"),
  }),
});

Analyzer pipeline + 繁/簡 normalization

pipeline() composes char filters → a segmenter → token filters into a Tokenizer. Char filters are just (text) => string, so anything of that shape drops in — including OpenCC's converter, which already has that signature. That's all you need to fold Traditional/Simplified Chinese (script and regional vocabulary, e.g. 软件↔軟體) so a keyword query matches across variants — no extra Kura package required:

import * as OpenCC from "opencc-js"; // npm i opencc-js  (MIT; bundled dictionary data is Apache-2.0)
import { pipeline } from "@kurajs/search";
import { cjkSegmenter } from "@kurajs/tokenizers";

// Fold everything to Traditional-Taiwan (idempotent on text already in that variant),
// then segment. Run the SAME pipeline at index and query time so terms line up.
const zhTW = pipeline({
  pre: [OpenCC.Converter({ from: "cn", to: "twp" })],
  segment: cjkSegmenter("zh-TW"),
});

// In a Kura docs app: defineKura({ tokenizer: byLocale({ "zh-TW": zhTW }) })

OpenCC ships ~5 MB of dictionaries, so only sites that need cross-variant keyword matching pull it in. Most sites don't: a single-variant corpus is already consistent, and the hybrid vector half bridges 繁/簡 semantically on its own.

Exports

  • Bm25, rrf, rrfScored
  • Tokenizer toolkit: latinTokenizer, byLocale, pipeline, lowercase, minLength, stopwords
  • Types: Tokenizer, TokenizerResolver, CharFilter, TokenFilter, Bm25Record, Bm25Hit, …