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

@billie-coop/seaq

v2.0.0

Published

Zero-dependency fuzzy search — one function, no setup, no index to manage

Downloads

559

Readme

seaq

Zero-dependency fuzzy search. One function, no setup, no index to manage.

import { seaq } from '@billie-coop/seaq';

const results = seaq(contacts, 'john', { keys: ['name', 'email'] });

Works the same whether your list has 20 items or 20,000 -- no refactoring needed. Search the same list again and seaq indexes it for you.

Docs & live playground → Try seaq on your own JSON and compare it side by side with fuzzysort, Fuse.js, MiniSearch, uFuzzy, and Lunr.

Install

npm install @billie-coop/seaq

seaq 2.0 is published as @billie-coop/seaq. The unscoped seaq package (1.x) is deprecated. To upgrade from 1.x, see the CHANGELOG.

Usage

Search objects by key

const contacts = [
  { name: 'John Smith', email: '[email protected]' },
  { name: 'Jane Doe', email: '[email protected]' },
];

seaq(contacts, 'jo', { keys: ['name', 'email'] });
// => [{ name: 'John Smith', ... }, { name: 'Jane Doe', ... }]  (John ranked first)

Shorthand, swapped letters, word order and typos

seaq is built for what people actually type into a search box:

const people = [
  { firstName: 'Stephen', lastName: 'Laughton' },
  { firstName: 'Steve', lastName: 'Lawson' },
];
const keys = ['firstName', 'lastName'];

seaq(people, 'steplau', { keys });        // shorthand: word prefixes typed together
seaq(people, 'laguht', { keys });         // adjacent letters swapped
seaq(people, 'laughton steph', { keys }); // words in any order
seaq(people, 'stephin', { keys });        // a typo: "i" isn't in "Stephen"
// => Stephen Laughton ranks first for each

Shorthand, acronyms, adjacent swaps and word order work at every fuzziness; each swap or a reversed word order costs a little score. Typos -- characters that aren't in the item at all -- need fuzziness above 0. The default 0.2 allows them at a lower score; fuzziness: 0 rejects them.

Nested objects (dot notation)

const users = [
  { name: 'Alice', address: { city: 'New York' } },
  { name: 'Bob', address: { city: 'Los Angeles' } },
];

seaq(users, 'new york', { keys: ['address.city'] });

Array traversal

Dot notation walks into arrays automatically. Given emails is an array of objects, 'emails.address' searches every element:

const people = [
  { name: 'Charlie', emails: [{ address: '[email protected]' }, { address: '[email protected]' }] },
];

seaq(people, 'work.com', { keys: ['emails.address'] });

Plain string arrays

No keys needed when searching strings directly:

seaq(['apple', 'banana', 'orange'], 'app');
// => ['apple']

Acronym matching

Characters that start a word score extra, so acronyms and initials find what they stand for. Capitals you type also earn a small bonus where the item has the same capital:

seaq(['Hillsdale Michigan', 'Historical Museum'], 'HiMi');
// => ['Hillsdale Michigan', 'Historical Museum']  (Hillsdale ranked first)

Cross-field matching

An item's values are joined with spaces and scored as one string, so queries can span fields:

seaq(contacts, 'john smith', { keys: ['firstName', 'lastName'] });
// Matches even though "john" is in firstName and "smith" is in lastName

Other languages

seaq searches Unicode text, so it isn't limited to English: Cyrillic, Greek, Arabic, Korean, Chinese, Japanese and other scripts work.

seaq(['Лев Толстой', 'Антон Чехов'], 'толст'); // ['Лев Толстой']
seaq(['北京市', '北京大学', '南京大学'], '北大'); // ['北京大学', '北京市']

Ranking was tuned on English. Word-start bonuses (for acronyms like "NYC") use the start of the text and ordinary spaces, without language-specific word segmentation, so text without spaces between words gets no bonus inside it. Swaps and typo tolerance work as usual.

Text isn't Unicode-normalized, and seaq doesn't fold accents ("jose" finds "José" only as a weaker fuzzy match), transliterate ("beijing" won't find "北京"), convert between hiragana and katakana, or match Korean initial consonants ("ㄱㄴ" won't find "강남").

Highlight ranges are inclusive JavaScript (UTF-16) offsets. They never split a character outside the BMP in half, but they can cover only part of a sequence that displays as one character: an accent stored as a separate combining mark, or one person in a combined emoji like 👩‍💻.

Match highlighting

Set includeMatches: true to get character-level match positions for building highlighted search results. Matches are reported per field value -- each entry names the key that matched and gives indices relative to that value:

const results = seaq(contacts, 'john smith', {
  keys: ['firstName', 'lastName'],
  includeMatches: true,
});
// => [{
//   item: { firstName: 'John', lastName: 'Smith', ... },
//   score: 0.94,
//   matches: [
//     { key: 'firstName', value: 'John',  indices: [[0, 3]], score: 0.94 },
//     { key: 'lastName',  value: 'Smith', indices: [[0, 4]], score: 0.94 },
//   ],
// }]

Match positions are only computed for the returned results. In the benchmark (an unindexed search of 10K contacts, top 10 results), includeMatches had no measurable cost (see BENCHMARKS.md); with more results returned, it costs more.

Repeated searches (typeahead)

You don't set anything up for a search box. The first search of an array just scans it. The second search of the same array builds an index, and later searches reuse it:

  • Items are prepared once. The index keeps each item's search string, lowercased, with the character classes it contains: one per letter a–z, five for digits, and one shared by everything else (all non-ASCII characters included).
  • Some items are ruled out without scoring. Strict searches (fuzziness: 0) skip items missing a class the query uses. Fuzzy searches skip items whose missing classes cap their score below what's already in the top results. The classes can't tell non-ASCII characters apart, so for other scripts this rules out much less, and the numbers below (English names) don't carry over.
  • Typing gets cheaper. In strict mode, when the query extends the previous one ("nat" → "nata"), only the previous matches are re-checked.
  • Results are identical to a search without the index.

In the benchmark on 10K contacts, a default search for "nath fe" took 2.3 ms without the index and 0.37 ms with it; with fuzziness: 0 it took 27 µs. Building the index and searching cost no more than one search without it. The index used about 1.3 MB of memory per 10K contacts.

The index is keyed on the array in a WeakMap, so it's garbage-collected with the list. Adding, removing or replacing items is detected automatically. Mutating an item in place is not detected once the array is indexed: replace the object (list[i] = { ...item, name }), or pass cache: false. A new array each render (e.g. items.filter(...)) is a new list, so it's scanned like any first search.

Control it with the cache option:

seaq(list, query, { cache: true });  // index on the first search
seaq(list, query, { cache: false }); // never index; always re-read the items

API

seaq<T>(list: T[], query: string, options?: SeaqOptions<T>): T[]
seaq<T>(list: T[], query: string, options: SeaqOptions<T> & { includeMatches: true }): SeaqResult<T>[]

Returns a new array of matching items sorted by relevance (highest score first). The original array is never mutated. An empty query returns [].

Options

| Option | Type | Default | Description | |--------|------|---------|-------------| | keys | string[] | -- | Fields to search. Supports dot notation for nested properties ('address.city') and automatic array traversal ('emails.address'). An item's values are joined with spaces and searched as one string. Omit when searching a plain string[]; without keys, non-string items are matched against their JSON representation. | | fuzziness | number | 0.2 | Tolerance for query characters that can't be matched in order (typos, extra letters like johnn for john), from 0 to 1 (clamped). 0.2 = light typo tolerance: unmatched characters are allowed and scored lower. 0 = every query character must be matched (fastest). 0.5 = moderate. 0.8+ = very loose. Shorthand (steplau), acronyms, adjacent swaps (laguht) and any word order match at every setting. | | limit | number | 10 | Maximum results to return. Uses a min-heap internally for O(n log k) selection, faster than full-sorting then slicing. Set to Infinity to return all matches; 0 or negative returns []. | | threshold | number | 0.3 | Relative score cutoff. Results scoring below topScore * threshold are dropped. 0 = no filtering (return everything with score > 0). 1 = only results tied with the best score, however low it is. Note: higher = stricter -- the opposite polarity of Fuse.js's threshold. | | includeMatches | boolean | false | When true, returns SeaqResult<T> objects with per-field match metadata (character positions, matched value, per-match score) instead of plain items. | | cache | boolean | -- | Unset: an array is indexed on its second search. true: indexed on the first search. false: never indexed. Results are identical either way. Items mutated in place aren't detected once indexed -- replace them instead. See Repeated searches. |

Types

interface SeaqResult<T> {
  item: T;
  score: number;
  matches: SeaqMatch[];
}

interface SeaqMatch {
  key?: string;      // Field key (undefined without keys)
  value: string;     // The field value that was scored; indices are relative to it
  indices: [number, number][];  // Highlight ranges as [start, end] pairs (inclusive)
  score: number;     // The item's score
}

Feature comparison

| Feature | seaq | fuzzysort | fuse.js | minisearch | ufuzzy | lunr | |---------|:----:|:---------:|:-------:|:----------:|:------:|:----:| | Exact match | yes | yes | yes | yes | yes | yes | | Fuzzy/typo tolerance | yes | no | yes | partial | yes | partial | | Partial/prefix match | yes | yes | yes | yes | yes | yes | | Acronym bonus | yes | yes | weak | no | no | no | | Nested object access | yes | yes | yes | via extractField | no | via extractor | | Array field traversal | yes | via getter | partial | no | no | no | | Cross-field matching | yes | yes | via logical query | yes (per word) | no | yes (per word) | | Match highlighting | yes | yes | yes | yes | yes | no | | Index | automatic | optional | required | required | no | required | | Zero dependencies | yes | yes | yes | yes | yes | yes |

When to use seaq

seaq is a good fit when:

  • You want zero setup -- no constructor, no addAll, no index step; one function call
  • Users type shorthand, initials, swapped letters or small typos
  • Your list is dynamic -- new data each render, where an index built up front would have to be rebuilt or updated
  • You need to search nested objects or arrays without manual flattening
  • Acronym matching matters (e.g., "NYC" matching "New York City")
  • Your list size is unpredictable -- works from 20 items to 20,000 without API changes

Consider alternatives when:

  • You repeatedly search a large static dataset and need the most throughput -- MiniSearch and Lunr use inverted indexes that answer word queries in microseconds. seaq's automatic index closes much of the gap, but an inverted index still wins on raw repeated-query speed
  • You only search flat string arrays and need maximum throughput -- uFuzzy is purpose-built for this
  • You never need typo tolerance and want the fastest search while the user types -- fuzzysort only matches characters in order, and its snapshot() re-checks only the previous matches on each keystroke
  • You need features like stemming, stopwords, or boolean queries -- Lunr and MiniSearch have full-text search capabilities that seaq does not

For benchmark methodology and detailed performance numbers, see BENCHMARKS.md.

License

MIT