@blackglory/aho-corasick
TypeScript icon, indicating that this package has built-in type declarations

0.1.27 • Public • Published

aho-corasick

A simple Node.js wrapper for Rust's daachorse.

It's faster than the fastest pure JS implementation I know of, and it eats less memory.

Install

npm install --save @blackglory/aho-corasick
# or
yarn add @blackglory/aho-corasick

API

class AhoCorasick {
  constructor(
    patterns: string[]
  , options: { caseSensitive: boolean }
  )

  isMatch(text: string): boolean
  findAll(text: string): string[]
}

Benchmark

The patterns come from the title of the Chinese Wikipedia. The samples come from the text of the Chinese Wikipedia.

Compilation Matching
fastscan 2351 op/s 16.8 op/s
aho-corasick 2348 op/s 63.5 op/s

The results of the benchmark are relative values, which will change according to different patterns and samples.

Package Sidebar

Install

npm i @blackglory/aho-corasick

Weekly Downloads

4

Version

0.1.27

License

MIT

Unpacked Size

20.8 kB

Total Files

18

Last publish

Collaborators

  • black_glory