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 🙏

© 2024 – Pkg Stats / Ryan Hefner

haiku-search

v0.1.0

Published

A fast and memory-efficient fuzzy search library for text documents.

Downloads

2

Readme

Haiku-Search

Build Status

Overview

Haiku-Search is a high-performance fuzzy search library designed for web applications. It is built using Rust and compiled to WebAssembly, providing lightning-fast search capabilities directly in the browser. This combination allows Haiku-Search to execute complex search algorithms efficiently, taking advantage of Rust's performance and safety features.

Powered by Rust and WebAssembly

Haiku-Search leverages the power of Rust and WebAssembly to run directly in web browsers, offering significant performance improvements over traditional JavaScript search libraries. By compiling to WebAssembly, Haiku-Search provides near-native speed, making it ideal for applications requiring quick search responses on large datasets.

Algorithms

Haiku-Search implements two primary algorithms:

  • N-gram Indexing: This technique breaks down text into chunks (n-grams) and indexes them for quick lookup, allowing us to quickly narrow down potential matches.
  • Bitap Algorithm: For precise matching, Haiku-Search uses the Bitap algorithm, which supports a configurable number of errors. It is effective for short to medium text lengths and allows for approximate string matching.

Installation

WIP Since Haiku-Search is compiled to WebAssembly and not published on NPM, it can be included in your project by directly linking to the generated WebAssembly and JavaScript loader files. Here is how you can include it in your web project:

<script type="module">
    import init, { SearchConfig, SearchEngine } from './path/to/haiku_pkg/haiku.js';

    async function run() {
        await init(); // Initialize the wasm module
        const config = new SearchConfig(3, 1); // Configure ngram size and max distance
        const engine = new SearchEngine(["hello world", "hi there"], config);
        console.log(engine.search("hello"));
    }

    run();
</script>

Usage Example

Here’s a quick example on how to use Haiku-Search in a web application:

import init, { SearchConfig, SearchEngine } from './path/to/haiku_pkg/haiku.js';

async function performSearch() {
    await init();
    const config = new SearchConfig(3, 1); // ngram size and max allowed errors
    const engine = new SearchEngine(["search me", "search me not"], config);
    const results = engine.search("search");
    console.log(results);
}
performSearch();

Performance Comparison to Fuse.js

Haiku-Search is designed to be significantly faster than traditional JavaScript libraries like Fuse.js. In benchmarks, Haiku-Search performs searches up to 13x faster than Fuse.js.

image

You can see this chart live here: Haiku-Search vs Fuse.js Benchmark Results.

Known Limitations

  • Unicode Support: Haiku-Search does not currently support unicode characters, which may limit its use in applications requiring internationalization.
  • Pattern Length: The Bitap algorithm used in Haiku-Search supports patterns up to 32 characters long due to limitations in handling bit masks.

Roadmap

  • Add unicode support
  • Improve memory footprint
  • Improve code documentation

Contributing

Contributions to Haiku-Search are welcome! If you're looking to contribute, please:

  • Check out the current issues on GitHub, especially those tagged as "good first issue".
  • Fork the repository and make your changes.
  • Write clear, commented code.
  • Ensure your changes pass all existing tests and add new tests for added functionality.
  • Submit a pull request with a detailed description of your changes.

For major changes, please open an issue first to discuss what you would like to change.

Thank you for your interest in improving Haiku-Search!