New:Socket for Asana Is Now Available.Learn more
Get Started

@stll/text-search

Package Overview
Dependencies
Maintainers
1
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@stll/text-search

Multi-engine text search orchestrator for Node.js and Bun. Routes literals, regex, and fuzzy patterns to the right engine automatically.

latest
Source
npmnpm
Version
1.0.11
Version published
Weekly downloads
40
53.85%
Maintainers
1
Weekly downloads
 
Created
Source

Stella

Multi-engine text search orchestrator for Node.js and Bun. It classifies each pattern once, routes literals to Aho-Corasick, regex to RegexSet, fuzzy entries to FuzzySearch, and merges the results into one stable match stream.

Part of the @stll text search ecosystem: @stll/regex-set, @stll/aho-corasick, @stll/fuzzy-search.

Install

Node.js / Bun:

npm install @stll/text-search
# or
bun add @stll/text-search

@stll/text-search ships the engine packages as regular dependencies. You do not install them separately unless you want to use the lower-level engine APIs directly.

Browser / WebAssembly:

npm install @stll/text-search-wasm
# or
bun add @stll/text-search-wasm

Vite

@stll/text-search-wasm depends on the browser variants of the Stella engines. Import the bundled Vite plugin so those WASM loaders stay out of pre-bundling and keep their relative asset paths.

import stllTextSearchWasm from "@stll/text-search-wasm/vite";

export default {
  plugins: [stllTextSearchWasm()],
};

Usage

import { TextSearch } from "@stll/text-search";

const search = new TextSearch([
  "Confidential",
  "Attorney-Client Privilege",
  /\b\d{2}\.\d{2}\.\d{4}\b/,
  /\b[\w.+-]+@[\w-]+\.[\w]+\b/,
  { pattern: "Novák", distance: 1, name: "person" },
  { pattern: "s.r.o.", literal: true, name: "company-type" },
]);

const matches = search.findIter("Ing. Jan Novak, s.r.o., born 15.03.1990.");

Routing model

Patterns are classified once at construction time.

EngineUsed for
Aho-CorasickPure literals and explicit literal: true entries
RegexSetStandard regex patterns
FuzzySearchEntries with a distance field

Large alternation-heavy regexes are isolated into their own RegexSet instance so they do not poison the shared DFA for simpler patterns.

Rust core

The repository also contains stella-text-search-core in crates/core. It mirrors the orchestration layer: classification, engine routing, regex chunking, lazy prefilters, split literal search, match merging, and replacement. The crate is not published yet; it exists as the native core boundary for downstream bindings.

Options

new TextSearch(patterns, {
  unicodeBoundaries: true,
  wholeWords: false,
  maxAlternations: 50,
  fuzzyMetric: "levenshtein",
  normalizeDiacritics: false,
  caseInsensitive: false,
  overlapStrategy: "longest",
  allLiteral: false,
});

API

MethodReturnsDescription
findIter(text)Match[]Find matches in input text
isMatch(text)booleanFast yes/no check
whichMatch(text)number[]Pattern indices that matched
replaceAll(text, replacements)stringReplace matched ranges
lengthnumberNumber of configured patterns

Pattern entry types

"literal"
/\bregex\b/i
{ pattern: "\\d+", name: "number" }
{ pattern: "Novák", distance: 1, name: "person" }
{ pattern: "s.r.o.", literal: true, wholeWords: true }

Match shape

type Match = {
  pattern: number;
  start: number;
  end: number;
  text: string;
  name?: string;
  distance?: number;
};

The Match shape is aligned with the other Stella text-search packages.

Development

bun install
bun test
bun run lint
bun run format
bun run build
cargo fmt --all --check
cargo clippy --all-targets --locked
cargo test --locked

Built on

License

MIT

Keywords

aho-corasick

FAQs

Package last updated on 13 Aug 2026

Related posts